Let me explain you clearly. The expectation of script_1 - every month 25th it would run. Script_2 - every day and script_3 every quarterly month end. For eg. if script_1 fails due to any reason on 25th and if i re-run the main_script on 26th. In this scenario script_1 will not run on 26th but i would like to run on 26th because it failed on 25th but i tried re-running on next day or any other day on same month, if i re-run the main_Script for that month then it should script_1 should run. In this scenario if i take script_2 which runs every day shouldn't run for again because it was already successful on 25th daily run
Comments: break breaks a current for-loop or while-loop. exit exits the script. && runs the following command after a good exit status. || runs the command after a bad exit status.
If the exit status of the previous run matters, you need to save this somehow in a file, to be discovered in the next run. date +%e puts a leading space if day is less than 10. date +%d returns the plain decimal number.
Why check the current time? Why not simply schedule for 10:00 (daily at 10:00) in crontab?
Expanding a little on what MadeInGermany has already said...
Do you realize that there are 4 quarters in a year; not 3? Do you also realize that month numbers 4 and 8 are not the last month in any calendar quarter?
Are you aware that break has undefined behavior if it is invoked when you are not inside a for, while, or until loop? Although it is treated as a no-op by the Korn shell, it will give you a syntax error in bash.
What operating system (including version) are you using?
What shell (including version) are you using?
What exit code does script1.sh return when it succeeds. What exit codes does script1.sh return when it fails?
What exit code does script2.sh return when it succeeds. What exit codes does script2.sh return when it fails?
What exit code does script3.sh return when it succeeds. What exit codes does script3.sh return when it fails?
Even if you use cron to start your script, do you realize that there is no guarantee that any job will be started within one minute of its scheduled start time?
for success scenario it will not return any exit because there will be scenario where daily and 25th will come in same time.
If the script_1.sh fails then it should exit post script_2.sh completes
Your answers above demonstrate a complete lack of understanding of how running commands in your main script works, how all three of the scripts invoked by your main script work, and how shell programming works.
All of the actions taken in your main script are run synchronously, so there is absolutely no chance that if script_1.sh fails (or if it succeeds) it will not exit before script_2.sh starts. But, of course, if the command in your main script:
is invoked at any time other than the first minute of 10 o'clock in the morning, none of your numbered scripts will ever be run anyway. I see no reason why this test should be included in your script nor anything in the description of your problem that would make such a test desirable. Every command that is run synchronously returns an exit code before the next command in your script starts. Always. Unconditionally.
If you can't figure out whether or not any of the shell scripts you are invoking in your main script succeeded, there is absolutely no way that you can record whether or not they succeeded so you can re-run them the next day if they failed.
I am looking for a unix script which could run a job on 2, 4 and 7 working day of the month.
if the days are falling on the saturday/sunday. it should run on the next day.
Thank you.. (9 Replies)
Hi,
I want to run a job in cron on a specific date(say 25th of every month) excluding holidays. Can anyone provide some hints to do this? Thanks for any inputs. (1 Reply)
Hi all,
I currently have a UNIX file maintenance script that runs daily as a cron job.
Now I want to change the script and create functions/sub inside it that runs on a weekly or monthly basis.
To run all the scripts' daily maintenance, I want to schedule it in cron as simply maint.sh... (1 Reply)
Hello Experts,
I have a script which i want to run the on last day of every month.
let say I have backup.sh script which i want to run it every month last day.
Can anyone please help :confused:
thanks (4 Replies)
Hi,
I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it.
For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
hi all
i need a script which will find all the processes witht the name of xxx and kill all those processes that runs for more than 1 day.
Regards (3 Replies)
Hi All,
I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this.
My Requirment is as below:
Input for me will be 2000909(YYYYMM)
I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
I know I can't schedule this in cron and would have to write a wrapper around my script and schedule it in cron ....but not sure how do to this?
How do I exclude Monday if the 2nd day of the month falls on a Monday?
Thanks.
I tried this:
0 0 2 * 0,2-6 command
And I know this doesnt... (2 Replies)
Hi ,
I am relatively new to unix...
Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell..
This is very urgent.
Thanks for ur help... (7 Replies)