Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Cron and seti@home UNIX
This has become a major area of frustration for me. Specifically, I'm trying to get the command line version of setiathome to kick off on startup (and automatically if it goes down). In the past, I've had no problems with getting the Rhapsody version of seti@home running in a cron job, but that was before MacOS X as we know it came along. To make a long story short, I have tried every variation of users' crontabs to get this line in the cron execution pipe, and nothing seems to want to kick the process off. I have even resorted to Cronnix (excellent app) to get the job done. The line as it appears in my various crontabs:
0 * * * * cd [path to my seti dir here];[space]
./setiathome -nice 19 > /dev/console 2> /dev/console
[Editor's note: Line break inserted for readability; it's really one line, and replace '[space]' with a true space character.]

I'm on the verge of giving up, but postings on this site have given me hope (someone is making this command work).

Perhaps I'm missing something really obvious, but in any case, I need help. How do you make a cron job kick off? What am I missing -- or misunderstanding? Links to a good Cron or MacOS X (or FreeBSD) UNIX tutorial?
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)

Cron and seti@home | 10 comments | Create New Account
Click here to return to the 'Cron and seti@home' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Mac OS X Hints -
Authored by: babbage on Aug 22, '01 02:32:22PM
Works fine for me -- my instance of setiathome is launched via cron at startup and has, at current check, been running for just under 900 hours now:
2:20:55pm :chris% top -l1 | grep seti
  283 setiathome   0.0%  899 hrs   1    25   672  14.8M   564K  15.0M  18.3M
2:22:12pm :chris%

The lines in my /etc/crontab are:

# launch seti@home on boot
0 * * * * chris cd /Users/chris/Applications/setiathome; ./setiathome -email -niCe 19 > /dev/console 2> /dev/console
0 * * * * root  chmod 0777 /Users/chris/Applications/setiathome/lock.sah >/dev/console 2>/dev/console

To be honest, I looked it up, locked it in, and forgot about it, so I forget exactly what these lines are doing in every detail, but suffice to say that they work just fine. The only glitch is that I get some unwanted messages to the console: "unable to start, file is locked" or something to that effect, which makes sense because the process is still running. If it was really a problem I'd write a launch wrapper to fork & exec like Apache does (have a conductor script that makes sure setiathome is running & launches it if not), but there really hasn't been the need for it -- the warnings don't bug me.

If this doesn't help you, post more info -- what you've tried, what went wrong, etc.

[ Reply to This | # ]

Mac OS X Hints -
Authored by: wallyfoo on Aug 22, '01 02:49:21PM
Is that in your user crontab? Or the system crontab, or root, or what? Which of the various cron files are you putting that line into to get it to kick off on startup? I've tried my crontab, root's, and system. What is the path of the cron file that line needs to be put into? I think that's what I'm doing wrong. I can't find the right file to get cron to do its magic on startup. That's what I expect. Or if I've found the correct file, then its proper activation eludes me. I suppose I don't fully understand the launch order for things on MacOS X, or cron for that matter, yet.

Path of appropriate cron file?
Command to get that cron file to become active?

You have no idea how much of a learning experience this has been for me. And by that I mean it's been really trying. : ]

[ Reply to This | # ]
Mac OS X Hints -
Authored by: babbage on Aug 22, '01 05:18:15PM
Is that in your user crontab?

I meant what I said: it's in

Sorry I don't understand the cron system better such that I could explain how it works... :(

[ Reply to This | # ]
Mac OS X Hints -
Authored by: wallyfoo on Aug 22, '01 03:19:03PM

It's magic. I tried your syntax and it worked. now I have to go through the painful process of learning wy mine *didn't* work.

[ Reply to This | # ]
Why it didn't work for you.
Authored by: Anonymous on Aug 25, '01 04:03:49PM
Nothing magical - just shell choice.

You see, you used your own crontab (via crontab -e) to enter the script, but used the "setiathome > /dev/console 2> /dev/console" syntax to redirect stdout and stderr. The problem lies in the fact that your default shell is tcsh, and using 2> to redirect stderr only works for Bourne-style shells (sh/ksh/bash/etc). By putting in /etc/crontab, you got it to work because there is a line in /etc/crontab that says "SHELL=/bin/sh", so the 2> redirect works.

There are three ways you can fix your script so you can leave your system crontab alone. I recommend using one of them, rather than futzing with /etc/crontab, since the system crontab may get overwritten when you reinstall, and in general you don't want to mess with system stuff. 1) Bring your script into csh compliance. Use "setiathome >& /dev/console" to merge stdout and stderr . 2) Make your crontab use a Bourne shell. Use Cronnix to set the SHELL environment variable to /bin/sh, or edit it yourself to include the line SHELL=/bin/sh 3) Have crontab call a standalone script. (Recommended) Make a file titled "Start.sah" or something similar. Put in it something like the following:


/path/to/setiathome -nice 19 > /dev/console 2> /dev/console
echo "Seti@Home started" > /dev/console
As stated, I recommend using option 3, in conjunction with the following trick. Put your crontab in ~/Library/init/crontab.mine. Use "crontab ~/Library/init/crontab.mine" as a command line alias (i.e. update_crontab). I don't think this works with CronniX, but it is nice, since the "permanent" copy of your crontab will live in your user directory, and thus will not get hosed when you move your User directory around for backup or reinstall purposes.

[ Reply to This | # ]
Mac OS X Hints -
Authored by: cyber.sonik on Aug 22, '01 03:55:33PM
I also wanted to run the CLI version of Seti@HOME but decided to use the StartupItems mechanism as found in OS X System Overview. At boot it gets launched and then cron isn't always trying to re-launch it. Here's what I did (as root): create the folder "StartupItems" in
/Library, create a folder named "SetiAtHome" in it, and then a file of the same name in that folder. Also, you need a StartupParameters.plist file in this folder. I placed the Seti@HOME
files in a "bin" folder in the "SetiAtHome" folder to make the whole thing portable.



# Start Seti@Home

. /etc/rc.common

if [ "${SETIATHOME:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Starting SETI@home"

cd /Library/StartupItems/SetiAtHome/bin; ./setiathome -email -nice 19 > /dev/null 2> /dev/null &


Description = "SETI@home CLI program";
Provides = ("SETI@home");
Requires = ("Disks");
Uses = ("Resolver");
OrderPreference = "Late";
Messages =
start = "Starting SETI@home";
stop = "Stopping SETI@home";

The first file needs to be made executable (chmod a+x), the line SETIATHOME=-YES- in
/etc/hostconfig toggles it on and off, and setiathome needs to be run once to set it up. I
hope this helps

[ Reply to This | # ]
Mac OS X Hints -
Authored by: wallyfoo on Aug 22, '01 04:33:12PM

You should bottle this and sell it, so to speak.

That's a great tip. What does the seti@home group say about bundling distros? Make a little install package with this setup and there'd be a ton of people grateful, I'm sure.

Thanks so much.

[ Reply to This | # ]
Mac OS X Hints -
Authored by: Hes Nikke on Dec 21, '01 09:33:02PM

in a worst case senerio one could make a shell script that does this :)


if script is run as root/sudo

...make directory /Library/StartupItems/SetiAtHome/
...make directory /Library/StartupItems/SetiAtHome/bin/

...copy SetiAtHome from package to /Library/StartupItems/SetiAtHome/SetiAtHome
...copy StartupParameters.plist from package to /Library/StartupItems/SetiAtHome/StartupParameters.plist

...chmod /Library/StartupItems/SetiAtHome/SetiAtHome if nessary SAH
...unpack SAH to /Library/StartupItems/SetiAtHome/bin/ SAH with the stop after download switch

...output that this needs to be run as root/sudo

and there we go!

anyone wanna make the shell script?

[ Reply to This | # ]
Mac OS X Hints -
Authored by: Hes Nikke on Dec 22, '01 02:18:17AM
ok, this should do it, requires wget (use fink)
sah installer
run tar -xvf sah.tar
in the sah folder, run ./install.sah
enjoy! :)

if this doesn't work right, email me, this isn't tested, i've got a diffrent implimentation of SAH on 3 machines!

[ Reply to This | # ]
Mac OS X Hints -
Authored by: Hes Nikke on Aug 05, '03 07:14:02PM
wow some time in the past 2 years the above linked file got moved! well, since i was fixing the URL, i figured i'd go the whole 9 yards, and make sure that the script actually works (and it does) enjoy :D

vacuums do not suck. they merely provide an absence that allows other objects to take the place of what becomes absent.

[ Reply to This | # ]