How to make a Daily Cron only for a month? I want to run a certain command everyday at 2PM but want to run It only for a month, and after the month it should stop on its own. How to make it?
Create a file e.g. /etc/cron.d/onlyfor1month
Put this into that file:
0 14 * 12 * root /this/is/run/everydayofthemonth/at2pm 0 15 31 12 * root rm -f /etc/cron.d/onlyfor1month
The first line runs the job every day in December at 2pm, as root (change the
root if it should be run as another user).
The second line runs on the 31st of December at 3pm (also as root, this must be root) and removes the cron file, so that it won't cause the job to be run again next December.