Boinc and crontab

Questions and Answers : Unix/Linux : Boinc and crontab
Message board moderation

To post messages, you must log in.

AuthorMessage
Cold E@rth

Send message
Joined: 12 Apr 06
Posts: 5
Credit: 3,102,549
RAC: 0
Australia
Message 662247 - Posted: 19 Oct 2007, 1:28:31 UTC

Hi guys,

I'm running FC7 and have installed Boinc and connected to Seti, however I want to setup the 'run_manager' program/script as a cron job every hour, so that in the event of my server restarting, or the program unexpectedly aborting, it will start back up again on the hour, every hour (actually 1 min past). If the program is already running, then it shouldn't run it again.

I have added the following line to my /etc/crontab file:

01 * * * * /home/BOINC/run_manager &

I'm not totally proficient with Linux, but my understanding is this will run the 'run_manager' program every hour at XX:01, and run the program in the background.

However this doesn't seem to work. Any hints? I had this working when I first installed FC4 a couple of years ago, but I have since upgraded my server after the hardware failed, so I don't have any of my old files/configuration settings.


Michael Weeks
ID: 662247 · Report as offensive
DJStarfox

Send message
Joined: 23 May 01
Posts: 1066
Credit: 1,226,053
RAC: 2
United States
Message 662292 - Posted: 19 Oct 2007, 2:50:32 UTC - in response to Message 662247.  

Did you have this cron job working in the past? I'm not sure that would work properly.

A much better way would be to include BOINC as a service on startup. The run_manager script is for the GUI, but boinc can be run as a daemon. Just run the GUI whenever you want to monitor/control it. (The manager will start the boinc client on localhost automatically if it detects it's not running.)

Instructions for doing running BOINC as a daemon on startup (and much more) can be found here:
http://www.spy-hill.net/~myers/help/boinc/unix.html

If you really want to go overboard, you could write a script (and cron it every hour) to check that boinc is running. Then, this script could take one of several actions, including restarting boinc via the "/sbin/service boinc restart" command. However, the service startup script (via the link above) should work well. I have it installed (partially) on my system, enough to make the service command work.
ID: 662292 · Report as offensive
Bryn
Avatar

Send message
Joined: 2 Jun 01
Posts: 85
Credit: 925,923
RAC: 26
United Kingdom
Message 662827 - Posted: 19 Oct 2007, 23:36:24 UTC - in response to Message 662247.  

I want to setup the 'run_manager' program/script as a cron job every hour

As DJStarfox says, run_manager is for the GUI, and including BOINC as a service is a better, more 'system-friendly' way of handling it - but you could kick BOINC via CRON with:

01 * * * * /home/BOINC/kick.sh

where kick.sh contains:
---snip---
cd /home/BOINC
# start boinc if not already running
if ! ps ax|grep boinc|grep -v grep > /dev/null; then
exec ./boinc
fi
---snip---

Save this to your BOINC directory then do:
chmod +x kick.sh
to make it executable

BOINC itself will be crunching away without the GUI, but you can start that manually whenever you want to monitor BOINC.

To err is human; to moo, bovine.
ID: 662827 · Report as offensive
Cold E@rth

Send message
Joined: 12 Apr 06
Posts: 5
Credit: 3,102,549
RAC: 0
Australia
Message 664381 - Posted: 22 Oct 2007, 13:51:35 UTC

Ok, so I finally decided to forget about the crontab, and just run the client as a service.

I followed the instructions on the website DJStarfox listed, and it works, however whenever I restart my computer, it seems that the processes aren't killed correctly, as when it starts up the service at bootup, it comes up with a lockfile error and fails. If I login and restart the service however, all is good.

Any suggestions? Is there a way to automatically restart this service without user intervention?

Michael Weeks
ID: 664381 · Report as offensive
DJStarfox

Send message
Joined: 23 May 01
Posts: 1066
Credit: 1,226,053
RAC: 2
United States
Message 664719 - Posted: 23 Oct 2007, 0:14:38 UTC - in response to Message 664381.  

Ok, so I finally decided to forget about the crontab, and just run the client as a service.

I followed the instructions on the website DJStarfox listed, and it works, however whenever I restart my computer, it seems that the processes aren't killed correctly, as when it starts up the service at bootup, it comes up with a lockfile error and fails. If I login and restart the service however, all is good.

Any suggestions? Is there a way to automatically restart this service without user intervention?

Michael Weeks


Edit file /etc/rc.d/init.d/boinc

Where you see the stop) function declaration, add a line that reads:
rm -f /home/boinc/BOINC/lockfile

...before the line that says "./boinc_cmd --quit". Be sure to replace the directory above with the correct directory for your system.

I think I found a bug in the guy's script that I linked for you. Adding that line should cause the "service stop" command to delete the lockfile.
ID: 664719 · Report as offensive
Cold E@rth

Send message
Joined: 12 Apr 06
Posts: 5
Credit: 3,102,549
RAC: 0
Australia
Message 665071 - Posted: 23 Oct 2007, 12:19:38 UTC - in response to Message 664719.  

Edit file /etc/rc.d/init.d/boinc

Where you see the stop) function declaration, add a line that reads:
rm -f /home/boinc/BOINC/lockfile

...before the line that says "./boinc_cmd --quit". Be sure to replace the directory above with the correct directory for your system.

I think I found a bug in the guy's script that I linked for you. Adding that line should cause the "service stop" command to delete the lockfile.



I can't find the line "./boinc_cmd --quit" anywhere in the file. However according to the script, the stop) function already deletes the lockfile:


## Functions: $1 is one of start|stop|status|restart

case "$1" in
start)
cd $BOINCDIR

if [ -f lockfile ] ; then
echo -n "Another instance of BOINC is running (lockfile exists)."
echo_failure
echo
exit 4
fi

if [ ! -d projects ] ; then
echo -n "The BOINC client requires initialization."
echo_warning
echo
fi

echo -n "Starting BOINC client as a daemon: "
su $BOINCUSER -c "$BOINCEXE $BOINCOPTS" >>$LOGFILE 2>>$ERRORLOG &
sleep 1
PID=`pidof -s -x -o $$ -o $PPID -o %PPID $BOINCEXE`
if [ $PID ]; then
[ -d $LOCKDIR ] && touch $LOCKDIR/boinc
echo_success
else
echo_failure
fi
echo
;;

stop)
cd $BOINCDIR
if [ ! -f lockfile -a ! -f $LOCKDIR/boinc ] ; then
echo -n "BOINC is not running (no lockfiles found)."
echo_success
else
echo -n "Stopping BOINC client daemon: "
killproc $BOINCEXE && echo_success || echo_failure
# clean up in any case
rm -f $BOINCDIR/lockfile
rm -f $LOCKDIR/boinc
fi
echo
;;

restart)
$0 stop
$0 start
;;


This is the script that you linked to.

Obviously the stop) function works in deleting the lockfile, because when I used the restart) function (like I said previously) everything works.

So how can I get around this? The only solution I can think of would be to delete the lockfile on startup before the script executes.

Michael Weeks
ID: 665071 · Report as offensive
DJStarfox

Send message
Joined: 23 May 01
Posts: 1066
Credit: 1,226,053
RAC: 2
United States
Message 665569 - Posted: 24 Oct 2007, 6:18:10 UTC - in response to Message 665071.  

Post the contents of files:
error.log
boinc.log

These files should be in your BOINC folder. Also, are you starting the service using root or using your personal login? Does it work either way if you start boinc manually? Check permissions on the BOINC folder and settings in file /etc/sysconfig/boinc.
ID: 665569 · Report as offensive
Profile Toby
Volunteer tester
Avatar

Send message
Joined: 26 Oct 00
Posts: 1005
Credit: 6,366,949
RAC: 0
United States
Message 670439 - Posted: 1 Nov 2007, 7:36:15 UTC

I'm not very familiar with Fedora but I would take a look at your package manager (yum?) and see if it has a package for BOINC. If it does, it will come with all these scripts already in the right places and doing the right things.
A member of The Knights Who Say NI!
For rankings, history graphs and more, check out:
My BOINC stats site
ID: 670439 · Report as offensive
DJStarfox

Send message
Joined: 23 May 01
Posts: 1066
Credit: 1,226,053
RAC: 2
United States
Message 670963 - Posted: 2 Nov 2007, 2:41:00 UTC - in response to Message 670439.  

I'm not very familiar with Fedora but I would take a look at your package manager (yum?) and see if it has a package for BOINC. If it does, it will come with all these scripts already in the right places and doing the right things.


No such package yet. The download from BOINC website is pretty easy to install though. If I had the time and permission, I could probably just repackage their script into an .rpm file for the public.

ID: 670963 · Report as offensive

Questions and Answers : Unix/Linux : Boinc and crontab


 
©2024 University of California
 
SETI@home and Astropulse are funded by grants from the National Science Foundation, NASA, and donations from SETI@home volunteers. AstroPulse is funded in part by the NSF through grant AST-0307956.