Quantcast
Channel: SmallNetBuilder Forums
Viewing all articles
Browse latest Browse all 6885

Schedule a task each last day of month

$
0
0
It's a bit tricky, but you can do it

Use the following in /jffs/scripts/init-start script :

Code:

cru a THEIDYOUWANT "59 23 28-31 * * [[ \`date +\%d\` -gt \`date +\%d -D \%s -d \$(( \$(date +\%s) + 86400))\` ]] && THECOMMANDYOUWANT"
Replace :
THEIDYOUWANT, by a unique ID along your cru commands

THECOMMANDYOUWANT, by the command you want to execute each last day of month (usually a shell script)

Do not forget antislashs ( \ ) in script. Test without them directly on command line

It will execute "THECOMMANDYOUWANT" each last day of the month.
THECOMMANDYOUWANT is triggered at 23:59 when the value of the next day is lower than the current day, tested between 28 & 31 (for handling february)

Viewing all articles
Browse latest Browse all 6885

Trending Articles