Techtrekking

mynotes cronjob

By Pravin

open a crontab

crontab -e

Run everyday

# every week day 0 9 * * * /home/ubuntu/novanenv/bin/python /path/to/your/script.py >> /path/to/your/logfile.log 2>&1 # every working day 0 9 * * 1-5 /home/ubuntu/novanenv/bin/python /path/to/your/script.py >> /path/to/your/logfile.log 2>&1 # weekly once on monday 0 9 * * 1 /home/ubuntu/novanenv/bin/python /path/to/your/script.py >> /path/to/your/logfile.log 2>&1
PositionNameValue RangeDescription
1stMinute0-59Specific minute.
0 = Top of the hour.
30 = Half past.
* = Every single minute.
2ndHour0-2324-hour format.
0 = Midnight.
9 = 9 AM.
13 = 1 PM.
23 = 11 PM.
3rdDay of Month1-31Specific Calendar Date.
Use this if you want to run on the "1st of the month" or "15th of the month".
4thMonth1-12The Month.
Use this to run only in "December" or "January".
5thDay of Week0-6The Weekly Cycle.
0 or 7 = Sunday
1 = Monday
5 = Friday

once cronjob changes are done, restart the cron

sudo systemctl status cron sudo systemctl stop cron sudo systemctl start cron sudo systemctl restart cron

check cronjob errors

grep CRON /var/log/syslog
Comments
No comments yet. Be the first to comment!
Leave a Comment
Your comment will be visible after approval.