crontab example
Here is the crontab code:
# start apache on reboot
@reboot mount -t ext3 /dev/sdf /opt/
@reboot /etc/init.d/httpd start
# start mysqld on reboot
@reboot /etc/init.d/mysqld start
*/10 * * * * /usr/bin/php /opt/www/cron/getlivestat.php
10 * * * * /usr/bin/php /opt/www/cron/generaterss.php
25 14 * * * /opt/www/cron/rotatelogs.sh
*/02 * * * * sh /opt/www/cron/imagedata_upload.sh >> /opt/www/cron/imagedataoutput.log
To set crontab for a particular user like webdoc, use command :
crontab -e -u webdoc
Syntax Description:
* * * * * command to be executed - - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +------- month (1 - 12) | | +--------- day of month (1 - 31) | +----------- hour (0 - 23) +------------- min (0 - 59) |
Example:
1. Set a crontab to execute a php file everyday at 0:10 am:
10 0 * * * /usr/bin/php /opt/www/html/mpplmatrix/upd_database.php >> /var/log/apache2/matrix_cron.log
Categories: linux