0

I want to set up a script that runs after my Linux starts up, and keep retrying (at an interval, say 1 minute) if fails. How do I do so?

Thanks!

1
  • This would be distro/version specific - or more precisely based on what init system you use - without knowing this, its pretty hard to answer. Its much more elegant in upstart or systemd
    – Journeyman Geek
    Aug 29, 2014 at 1:00

1 Answer 1

1

See this answer for how to run a script on startup. To keep retrying, write a wrapper for your script which determines if the script failed or not, and if it did, wait 1 minute then try again. It really depends what language you are writing in, so if you want more help, please provide more details.

You can create a loop with a bash script using these instructions.

i="0"

while [ $i -ne 1 ]
do

# Run your script here
# if script was successful, set $i to 1

sleep 60
done
1
  • 1
    And within the while loop you can use $? to ask for the return status of your script, just after the line that runs it.
    – jimm-cl
    Aug 27, 2014 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .