CRON

Posted by alex almazan Sun, 13 Apr 2008 06:21:00 GMT

Cron

Five values are available for scheduling automated processes
minute  hour   day of month  month  day of week                       
0-58    0-23      1-31       1-12     0-7  (0 or 7 is Sun,3 ltr abrvs)
examples

1.) create a cronjob for the user root that checks the amount of availabe space on the system every friday at 12:34 pm

34     12     *     *     5     /bin/df -h >>root.out --to create a file
34     12     *     *     5     df -h 

will mail to crontab user (MAILTO=user to customize)

2.) Create a cronjob as a regular user that lists the contents of /tmp at 4:56 am on Monday,February 3

56 04 3 2 1 /bin/ls -alh /tmp >> /root/tmpspace.out

(this one will run on every monday and on the third. Day of week or day of month get applied when the condition is met) You will have to write the logic in the script or * for every monday or * from just the third

CRON process snapshot

Posted by alex almazan Mon, 17 Dec 2007 22:13:00 GMT

Process information prior to server crash can provide insight into server instability. The following cron can help obtain details necessary to re-instill server stability. This should be used sparingly and in the most dire of circumstances.

*/1 * * * * uptime >> /root/status.txt ; ps -auwwwwx >> /root/status.txt ; free -m >> /root/status.txt
*/5 * * * * uptime >> /root/status5.txt ; ps -auwwwwx >> /root/status5.txt ; free -m >> /root/status5.txt
*/10 * * * * uptime >> /root/status10.txt ; ps -auwwwwx >> /root/status10.txt ; free -m >> /root/status10.txt 

CRON Log Delivery

Posted by alex almazan Mon, 17 Dec 2007 22:03:00 GMT

This CRON example covers a daily delivery of server logs, in this case mail specific.
5 0 * * *  /bin/mail -s "Daily requested mail log" user@domain.ltd < maillog > /dev/null 2>&1