In linux ec2 instance i want to run a cron job 3 Days once to automate a process once in three days as a sudo user in my linux ec2 instance.
Can anyone help me out with the cron.
In linux ec2 instance i want to run a cron job 3 Days once to automate a process once in three days as a sudo user in my linux ec2 instance.
Can anyone help me out with the cron.
You can create a cron that executes 3 days of the week and once you finish these three days delete it it.
$ crontab -e
And add the following line:
* * * * 1-3 sudo <your comand>
These is an explanation of the cron syntax:
┌────────── minute (0 - 59)
│ ┌──────── hour (0 - 23)
│ │ ┌────── day of month (1 - 31)
│ │ │ ┌──── month (1 - 12)
│ │ │ │ ┌── day of week (0 - 6 => Sunday - Saturday, or
│ │ │ │ │ 1 - 7 => Monday - Sunday)
↓ ↓ ↓ ↓ ↓
* * * * * command to be executed
And you can use the number of the days or the short name of the days:
0 - Sun Sunday
1 - Mon Monday
2 - Tue Tuesday
3 - Wed Wednesday
4 - Thu Thursday
5 - Fri Friday
6 - Sat Saturday
7 - Sun Sunday
This should do the job:
0 0 */3 * * sudo ...
\_/ \_/ | |
| | | Every week
| | |
| | Every month
| |
| Every third day
|
Midnight