Difference between revisions of "Cron"

From HiveTool
Jump to: navigation, search
Line 1: Line 1:
The software utility cron automates system maintenance or administration by scheduling jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. From the Greek word for time, χρόνος chronos. See [http://en.wikipedia.org/wiki/Cron] or read the man pages:
+
The software utility cron automates system maintenance or administration by scheduling jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. From the Greek word for time, χρόνος chronos. See http://en.wikipedia.org/wiki/Cron or read the man pages:
  
 
man crond
 
man crond

Revision as of 18:44, 22 December 2013

The software utility cron automates system maintenance or administration by scheduling jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals. From the Greek word for time, χρόνος chronos. See http://en.wikipedia.org/wiki/Cron or read the man pages:

man crond

crond is a background daemon that parses individual crontab files and executes commands on behalf of the users in question.

man crontab

      crontab -l [-u user] - list crontab for user
      crontab -e [-u user] - edit crontab for user


Listed below is a typical crontab file that reads the sensors, generate system status page and graphs, and records a sample of video:

#
# email me computer status at 6 pm
0 18 * * * /home/hivetool/ssmtp_test3 1> /dev/null
#
# email me hive  status every 24 hours (6 am)
0 6 * * * /home/hivetool/send_email.pl 1> /dev/null
#
# Check hive instruments every 5 minutes
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/hivetool/hive.sh
#
# Check the server status
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/hivetool/server_status.sh > /var/www/htdocs/server_status.txt
#
# grab a frame and record it as a jpg
4,9,14,19,24,29,34,39,44,49,54,59 * * * * /bin/timeout 60 /home/hivetool/grab_frame.sh 2> /home/hivetool/grab_frame.cron
#
# generate daily graph for hive at midnight
0 0 * * * /var/www/htdocs/graph_hive_variable.pl -m -o /var/www/htdocs/daily_filtered -h 300
0 0 * * * /var/www/htdocs/graph_hive_variable.pl -mr -o /var/www/htdocs/daily_raw -h 300
#
# generate wide graph with all the data at 5 minutes before midnight
55 23 * * * /var/www/htdocs/graph_hive_variable.pl -o /var/www/htdocs/all_filtered
55 23 * * * /var/www/htdocs/graph_hive_variable.pl -r -o /var/www/htdocs/all_raw
#
# record 60 seconds of audio stream at 4 am, 10 am, 4 pm and 10 pm
#0 4,10,16,22 * * * streamripper localhost:8000/hive1.ogg -l 60 -s -a /var/www/htdocs/audio/hive1_%D
#
# record 60 seconds of audio stream at 10:05 10:10 10:15 etc
#5,10,15,20,25,30,35,40,45,50,55 10 * * * streamripper localhost:8000/hive1.ogg -l 60 -s -a /var/www/htdocs/audio/hive1_%D
#
# record 30 seconds of video every 30 minutes
0,30  7,8,9,10,11,12,13,14,15,16,17 * * * /bin/timeout 60 /home/paul/rh 1> /home/paul/rh.cron
#