-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunOnDate_v.0.02.sh
38 lines (23 loc) · 957 Bytes
/
RunOnDate_v.0.02.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /bin/bash
#Script to run scripts on any date after period
#By Rosen Georgiev1 IBM Linux Support
#version = 0.0002
#Date = 21/8/2019
#You may execute this script with @daily option by cron
#Please reed the comments!
#To be executed as : this_script.sh other_task_script.sh
fIlename=`basename "$0"`
toDay=$((($(date +%s))/(3600*24))) #I am taking the Linux date ;)
startDate=$toDay #This will be changed by the first run!!! original: #startDate=$toDay#
taskToExecute=$1
daysToSkip=70 # change to desired days <<<<<
nextRunDate=$(( startDate + daysToSkip ))
sed -i -e "s/^startDate=\$toDay/startDate=$startDate/" $fIlename
if [[ $toDay -ge $startDate ]]; then
echo "Running the task";
. "$taskToExecute" && #this will execute the shell script you provide
sed -i -e "s/^startDate=$startDate/startDate=$nextRunDate/" $fIlename #overwriting the start date
else
echo "Next Date to execute is: $startDate"
fi
echo "Done at `date`"