Message boards :
Number crunching :
Linux boincKeepAlive.pl script
Message board moderation
Author | Message |
---|---|
jakub.hertyk Send message Joined: 9 Aug 05 Posts: 1 Credit: 694,598 RAC: 0 |
I've been using this script for the past three months, and I figured that other people might enjoy this also. It's for linux only, in perl, wrote it in 15 min. I have it set up as an hourly cron job. So if your computer crashes and restarts, this script will restart your boinc (removes the lockfile). Also, I sometimes get boinc stuck on something and the system load drops to 0.00 (days on end), if the load is 50% of your number of cpus, then a restart she gets. You have to have boinc setup to run on boot-up and might have to adjust the paths in the file as necessary. Jakub ******** START boincKeepAlive.pl #!/usr/bin/perl -w use strict; my $lockfile = "BOINC is stopped but lockfile exists."; my $stopped = "BOINC client is stopped."; my $slacking = "BOINC client is running but with a low system load."; my $boincStatus = qx (/etc/rc.d/init.d/boinc status); chomp ($boincStatus); if ($boincStatus eq $lockfile || $boincStatus eq $stopped) { &printStatus ($boincStatus); if ($boincStatus eq $lockfile) { qx (rm -rf /var/lib/boinc/lockfile); } my $startup = qx (/etc/rc.d/init.d/boinc start); &printLine ($startup); } elsif (&systemIdle) { &printStatus ($slacking); my $restart = qx (/etc/rc.d/init.d/boinc stop); &printLine ($restart); $restart = qx (/etc/rc.d/init.d/boinc start); &printLine ($restart); } sub systemIdle { my $cpus = qx (cat /proc/cpuinfo | grep processor | wc -l); chomp $cpus; if (substr (qx (uptime), -17, 4) < ($cpus / 2)) { return 1; } return 0; } sub printStatus { my $boincStatus = shift @_; my $currentDate = qx (date); my $hostname = qx (hostname); chomp ($currentDate); chomp ($hostname); my @date = split (" ", $currentDate); open (FILE, ">>/var/log/boincKeepAlive"); for (my $i = 1; $i < 5; $i++) { print FILE "$date[$i] "; } print FILE "$hostname $boincStatus\\n"; close (FILE); } sub printLine { my $line = shift @_; chomp ($line); open (FILE, ">>/var/log/boincKeepAlive"); print FILE "\\t$line\\n"; close (FILE); } ******** END boincKeepAlive.pl |
©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.