sysadmin - Crontab and its logs -


frist time writing crontab.

following structure of time , date

 # * * * * *  command execute  # │ │ │ │ │  # │ │ │ │ │  # │ │ │ │ └───── day of week (0 - 6) (0 6 sunday saturday, or use names; 7 sunday, same 0)  # │ │ │ └────────── month (1 - 12)  # │ │ └─────────────── day of month (1 - 31)  # │ └──────────────────── hour (0 - 23)  # └───────────────────────── min (0 - 59) 

i put entry following

00 06     * /bin/sh /opt/cleanup.sh 

think not woring.

where can see log of crontab??

usually cron commands' output sent owner via mail (man mail), when execute code returns output (stdout , stderr). when login should see "there new mails". don't know though if wrong cron schedules yours (see @fedorqui's reply) throw error log. in case have output , error of scheduled cron jobs on file instead of on mail, can redirect output this:

00 06 * * * /bin/sh /opt/cleanup.sh > /where/you/have/write/permission/cleanup.log 2>&1 

if want append rather overwrite, use 2 >, this:

00 06 * * * /bin/sh /opt/cleanup.sh >> /where/you/have/write/permission/cleanup.log 2>&1 

to disable log, schedule following:

00 06 * * * /bin/sh /opt/cleanup.sh > /dev/null 2>&1 

2>&1 means "redirect channel 2 (error) pointer of channel 1 (standard output)". standard output redirected file (/my/file.sh > /my/file.log).


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -