create cron job code example
Example 1: create cron job from command line
crontab -l > mycron
echo "00 09 * * 1-5 echo hello" >> mycron
crontab mycron
rm mycron
Example 2: cron example
crontab -e
10 * * * * /bin/sh backup.sh
0 */4 * * * /bin/sh backup.sh
0 9-17 * * * /bin/sh backup.sh
0 2 * * * /bin/sh backup.sh
0 0 * * MON /bin/sh backup.sh
0 0 * * 1-5 /bin/sh backup.sh
0 0 * * 0 /bin/sh backup.sh
0 0 1 * * /bin/sh backup.sh
0 0 1 */3 * /bin/sh backup.sh
0 0 1 1 * /bin/sh backup.sh
Example 3: add new cron job in linux
For editing the cron job file :
crontab -e
For listing all the running cron job
systemctl status cron ----OR---- crontab -l