简体   繁体   中英

How can I check whether the script started with cron job is completed?

I start a script and I want to start second one immediately after the first one is completed successfully?

The problem here is that this script can take 10min or 10hours according to specific cases and I do not want to fix the start of the second script. Also, I am using python to develop the script, so if you can provide me a solution with python control on the cron it will be OK.

Thank you,

您可以使用锁定文件来指示第一个脚本仍在运行。

You could use atexit module. As part of first script, you could register the function. From the registered function at exit, you could call the second script or execute the second script using system.

import atexit
def at_exit():
    print 'invoke the second script'
atexit.register(at_exit)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM