Sometimes you may want to execute a script on 2nd Monday or 4th Thursday only. A one line shell script can do it for you.
Consider this:
$ date +%a
The output is: Fri
Now to execute a script on first Friday:
$crontab -e
Now, append the following code in script:
# Run a script called myscript.sh on First Friday at 11:30:
30 11 1-7 * Fri [ "$(date '+%a')" == "Fri" ] && /path/to/myscript.sh
No comments:
Post a Comment