cron


to run from root (or user=controls on lhocds): crontab file.cron
syntax: 1,11,21,31,41,51 * * * * /cvs/cds/llo/web/scirun/S6/HardwareInjection/Details/bin/start_psinject -q -a
The '-a' means "automatic", i.e. it restarts psinject if it isn't currently running, and '-q' means quiet.
list cron tabs: crontab -l
remove cron tab: crontab -r
edit cron file: crontab -e
turn off cron emails with /dev/null: 1,11,21,31,41,51 * * * * /home/ethrane/test/call_gmfd &> /dev/null
better yet, write to a log file: 1,11,21,31,41,51 * * * * /home/ethrane/test/call_gmfd > /home/ethrane/test/call_gmfd.log

run code only if it's not already running (perl):
    $top = `top -b -n1 -u ethrane | grep "copyData.pl" | wc`;
    $top =~ s/ *//g;   $top =~ s/(.).*/\1/;
    if ($top>1) {
        print "copyData.pl is already running\n";
        exit;
    }
    else{
    ...
cron log is stored... /var/log/cron?


Back to Resources