Hey devs did you know that What does ***** (five asterisks) in a cron file mean? Today i am working on a project that i have to implemented cron job. I am a debian 10 buster user and i am implemented cron job in my local linux server. But when i saw that five asterisks then i get confused and thought that what does they mean?
Then i took a decision that i will share it with my codecheef readers. That's why i am here to teach you what does that five asterisks mean? See my cron tab try to understand:
Run this command to open your crontab.
env EDITOR=nano crontab -e
Look after running this command, this is my cron tab.
#!/bin/sh PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin * * * * * cd /var/www/html/batch-one && php artisan schedule:run >> /dev/null 2>&1
Here five asterisks mean i am running my cron job in every minute. If you are a linux user then run then you will get necessary things about it.
What does that five asterisks mean? See the below figure:
* * * * * command to execute │ │ │ │ │ │ │ │ │ └─── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0) │ │ │ └──────── month (1 - 12) │ │ └───────────── day of month (1 - 31) │ └────────────────── hour (0 - 23) └─────────────────────── min (0 - 59)
In details of this above example:
So open your cron tab and set
0 12 * * * cd ~/my/backup/folder && ./backup.sh
then it will execute every day at 12:00, The double ampersand
&& allows you to specify multiple commands that will run after each other. So hope you got the point. But to know details see the below example to better understand about five asterisks.
0 0 1 * * // simply it should run every 1st day of the month at 12:00 AM. 0 0 * * * // the job should run every hour. 30 5 10 * * // the job should run on the 10th of every month at 5:30 AM
Hope it will ehlp you.