create cron code example
Example 1: cronjob set time
Min
Hour
Day of Month
Month
Day of Week
// * * * * * cd /Applications/MAMP/htdocs/project_name && Console/cake SendEmail staging
// Example
// 0 23 * * * cd /Applications/MAMP/htdocs/project_name && Console/cake SendEmail staging
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: how to edit crontab in linux
Step 1 : crontab -e
Step 2 : Select your prefered editor for the file.
Steo 3 : Add the command that you want to execute from cron and save that file.
Example : 1 0 * * 0 rm /home/jones/*.log > /dev/null 2>&1
Step 4 : check if cron is activate using command
crontab -l