Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a cronjon which runs every 48 hours. But ideally what I want is that it must start running as soon as it stops. Can this be done? It is an sh script consisting of a python command. I am using Linux Mint 13.

Thank you

share|improve this question
It sounds to me that this is something the shell script—or better yet, the Python script itself—should control, not cron. What command are you running? Please consider posting the shell script and Python command here. – slhck Jan 19 '13 at 13:49
up vote 1 down vote accepted

One thing you could do is run the python command in an infinite loop, and then run the script once using cron. That way the script will be run again each time it finishes:

while true; do  ## Enter infinite loop
   sleep 5;   ## Wait for 5 seconds
   python -c 'print("hello world")'  ## Run your python command

If you save that script as, for example, ~/ and make it executable (chmod +x ~/, you can set it to run once on system boot using the @reboot prefix. Add this line to your crontab:

@reboot ~/

So, the BASH script will start on system boot and it will wait 5 seconds, run the python command and then keep doing so indefinitely.

A better, or at least more *nixy, way of doing this would be to add script to /etc/init.d.

share|improve this answer
I will run this on Amazon EC2 so reboot wont be required. – Rishi Jan 20 '13 at 7:43

You must log in to answer this question.

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