0

Hi,

I'm new to the forum & new to ,linux scripting so I'm hoping someone can help me out.

I have a crontab that calls 2 scripts like :

47 14 * * * /myFirstScript.sh

48 14 * * * /mySecondScript.sh

they don't do anything useful yet - just write to files; but is there a way of if the first script fails to not run the second script? is there a flag or anything like that I can use?

Thanks,

ch

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by linux
0

I can only think of using a log file of sorts. At the beginning of your first script have it output a '0' (false) to the log file. At the end of the script, upon successful execution, have it output a '1'.

In your second script you can then read in from the log file - if it is a '1', execute - otherwise don't.

Alternatively, you can have the first script call the second script.

Thirdly, if you need the second script to execute at a certain time, you can schedule the second script from the first script with 'at'. So at the end of the first script you would have something like:

echo "/path/to/myscript.sh" | at 0500

In this manner, your script will be executed at 5AM.
The at command is a kind of interface to the cron daemon - but the usage is a little more user friendly, and you can script it directly into your script to schedule upon successful completion. Depending on what you need done, this may be your best bet.

0

Better idea is just to have the first script execute the second if it finishes successfully.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.