Bash scripting: detect first day of month
6,313
Solution 1
Don't do this. Instead use two separate cron jobs to invoke your tasks.
15 5 1 * * scripts/full_back_up
15 5 2-31 * * scripts/incremental_backup
Solution 2
Try
if [ `date +%d` != "01" ]
then
incremental_backup
else
full_backup
fi
Related videos on Youtube
Author by
coderlearner
Updated on September 17, 2022Comments
-
coderlearner almost 2 years
I wrote three bash files:
incremental_backup
full_backup
execution
Now I want another bash script do the following :
if (date is the start of month 1/-/----) then invoke `full_back_up` else invoke `incremental_backup`
How can I write this script?
-
MadHatter over 13 yearsYour answer's the same as mine, and earlier, so I deleted mine. You might want to de-capitalise the "I" in your fisrt "if", though!
-
user9517 over 13 yearsYou should leave your answer up. There are quite a lot of duplicate answers on the site. It all adds to the community.