setup hourly crontab
Publisher: Psychz Networks, October 03,2015The crontab command comes with all Linux/Unix OS as a default program, it is designed to automate a task that needs to run daily, hourly, monthly or weekly. Setting up cron jobs is not too complicated, it requires a bit of messing around to get it to work how you want.
Before adding jobs to your crontab I recommend running, " crontab -l" to view what other jobs have been pre-configured. The output should be similar to my example shown below.
Example:
0 10 * * 3 wget -P /root/important https://example.com/file.html 0 13 * * 3 /usr/bin/bash /root/important/program.sh file.html
Now that we know what cron jobs exist on the local Linux/Unix machine, execute "crontab -e" to add jobs to the crontab. we'll proceed first by explaining the example job I have on my Linux machine.
This is the crontab time chart we'll use this as a reference.
* * * * * command to be executed - - - - - | | | | | | | | | ----- Day of week (0 - 7) (Sunday=0 or 7) | | | ------- Month (1 - 12) | | --------- Day of month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)
0 13 * * 3 /usr/bin/bash /root/important/program.sh file.html
1: Minute (0) Run on zero minutes 2: Hours (10) Run the 10th hour of the day 3: Day (*) Run daily 4: Month (*) Run every month 5: Day of the week(3) Wednesday 6: binary path /usr/bin/bash, and the progam to execute
Run cron job every 10min of every 2 hours
10 */2 * * * /usr/local/bin/program dosomething /dev/null 1&>2
1: Minute (10) Runs every 10 minutes of every hour
2: Hours (*/2)Runs every two of the day
3: Day (0-31) Runs every day of the week
4: Month (0-12 [12 == December]) Runs every month of the year
5: Day of the week(0-7 [7 or 0 == sunday]) Runs daily.
When you see */20 it usually means that it runs every 20 of every hour day etc....