Setting a cron job

Setting a cron job

How to set up cron?You can set multiple cron jobs from your cpanel >> cron jobs >> select standard or advanced.

* * * * *

minute hour date month day

Minute:- At what minute the commands will run and you can set values must be between 0 and 59.
Hour:- At what hour the commands will run and you can set values must be between 0 and 23. 0 is 12am and onwards.
Date:- At what date of the month the commands will run and you can set values between calendar month that is between 1 and 31.
Month:- At what month the command will run and you can set values between 1 and 12.
Day:- At which day of week commands will run and you can set values between 0 and 7 where 0,7 specify Sunday.

If you don’t want to specify a value for a field then just place * in that field.

Check following example to set cron job.

59 11 * * 2,6 /home/username/public_html/cgi-bin/abc.cgi
Above cgi script will run at 11:59 Tuesday and Saturday.

* 09 5 2,4,6 * /home/username/public_html/cgi-bin/abc.cgi

Above cgi script will run at morning 9 on every 5th date of February, april and June.

If you don’t want get output from your cron job then you have to redirect output to /dev/null.

e.g.
01 * 15,30 * * /home/username/public_html/cgi-bin/abc.cgi >> /dev/null
Above script will run hourly on every month 15 and 30th and output send to /dev/null.

If you want the cron job’s output will be sent to a particular email addres, as per below:

Please enter an email address where the cron output will be sent: [email protected]domainname.com

On the server, the cron job file will be stored with the username and file path is /var/spool/cron/username.

Sharing

1 Comments

  1. If you want to make changes in your corn job settings then you can edit them using crontab command ” corntab -e ”
    *) The crontab command performs syntax checking before allowing a newly edited crontab file to enter circulation.
    If the new crontab has a syntax error, crontab redirects you and ask if you want to edit again.
    *) To protect the crontab files, the crontab command makes root the owner of the crontab files.

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.