创建Cron作业 - Linux / Python [英] Creating a Cron Job - Linux / Python

查看:122
本文介绍了创建Cron作业 - Linux / Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要运行的Django脚本,



我认为可以通过bash命令。



Thing是脚本在长时间内导致内存泄漏,所以我想创建一个调用Python脚本的外部cron作业。所以脚本会在重新丢失内存时终止并重新启动。






有人可以指出我的方向吗?我对这个话题知之甚少,感觉有点迷失。

解决方案

如果您有可执行文件,请说 / home / bin / foobar ,重新启动脚本,并希望每10分钟运行一次(说),crontab条目需要:

  * / 10 * * * * / home / bin / foobar 

如果你保存这个(和任何你想要运行的任何其他定期工作),比如说,那么你可以把它们分割成10,每小时每一天。



/ home / bin / mycrontab ,然后只需执行 crontab / home / bin / crontab ,系统将执行其他操作(脚本与您的userid)



要查看在当前用户名(如果有的话)中已安排的定期工作,请执行 crontab -l <​​/ code>。


Hi I have a Django script that I need to run,

I think the commands could be called through bash.

Thing is the script causes memory leaks after a long a period of time, so I would like to create an external cron job which calls the Python script. So the script would terminate and restart while retaking the lost memory.


Can someone point me in the right direction? I know quite little on the subject, and feel a bit lost.

解决方案

If you have an executable, say /home/bin/foobar, that restarts the script, and want to run it (say) every 10 minutes, the crontab entry needs to be:

*/10 * * * *  /home/bin/foobar

which says to run it at every minute divisible by 10, every hour, every day.

If you save this (and any other periodic jobs you want to run) as, say, /home/bin/mycrontab, then just do crontab /home/bin/crontab and the system will do the rest (the script runs with your userid).

To see what periodic jobs you have already scheduled under the current userid, if any, do crontab -l.

这篇关于创建Cron作业 - Linux / Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆