Centos 7 – Cron examples

Last updated on July 2nd, 2019 at 01:18 pm

After setup cron don’t forget restart crond

To setup nano as default program
https://pro-wiki.com/knowledgebase/centos-7-how-to-set-nano-default-editor/

export VISUAL=nano; crontab -e
crontab -e

@reboot mail -s ‘PBX Rebooted’ [email protected]

crontab -e
12 10 * * 0 cat /root/.bash_history /history.txt

12 10 * * 0 mail -s 'PBX Hystory Attachment' -r [email protected] /history.txt

Explanation of Cron options

+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or Saturday=6)
| | | | |
* * * * * command to be executed
26 8 * * *

!!!To create Executable Bash script please run this command!!!

chmod +x /var/www/bckp.sh

Do not forget add this code to first line of your bash file

#!/bin/sh -

Cron Example of pro-wiki.com

30 20 * * * /var/www/backup.sh

To get crontab to run a task every 10 minutes you could type as follow:

*/10 * * * * /path/to/command

!! DO NOT FORGET TO RUN RESTART CRON Service after changes !!

systemctl restart crond

Leave a comment

Your email address will not be published. Required fields are marked *