2

I am attempting to run my compilation of scripts one after another every minute. Example: Assuming each script takes 2 seconds to finish:

start script 1 at 1:00, script 2 at 1:02, script 3 at 1:04, etc...

I assume it should look something like this

*/1 * * * * python script1.py && python script2.py && python script3.py
1
  • Your assumption should work as intended. Did you not try it? I'd only suggest to simplify your schedule to * * * * * which also fires every minute. Commented Dec 31, 2016 at 22:25

3 Answers 3

4
* * * * * python /path/to/script1.py ; python /path/to/script2.py ; python /path/to/script3.py

Use && if you want to run the second script only if the first script is successful (exit code is 0)

Use ; if you want to always run the second script irrespective of first script's exit code

Always provide full path to your script in crontab

Sign up to request clarification or add additional context in comments.

1 Comment

Correct. Cron does not load the user's profile. at, however, does load the profile.
1

Your cron entry is fine.

You may want to create a wrapper script that calls all your scripts in sequence.

Comments

1

Your cron entry should work. However, you may notice that it may fail because you didn't specify the absolute paths for the scripts.

2 Comments

where can I view the log of the scripts? Or like the python shell of the scripts in terminal
If what you meant by log is the stdout of the script, then you need to redirect stdout to a log file. By default, you should receive a mail when the task got executed. Just type mail in your console to check your mails.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.