Triyng想象为什么我的预定任务不会运行。 芹菜很好。
通过systemd
开始芹菜和芹菜的殴打[Unit]
Description=Celery Service
After=network.target
[Service]
Type=forking
User=awert
Group=awert
WorkingDirectory=/home/awert/checker_f/
ExecStart=/bin/sh -c '/home/awert/checker_f/checker_e/bin/celery multi start w1 -A checker_p -l info --logfile=/home/awert/celery/sworker.log --pidfile=/home/awert/celery/worker.pid --time-limit=21600 -E -S django'
ExecStop=/bin/sh -c '/home/awert/checker_f/checker_e/bin/celery multi stopwait w1 --pidfile=/home/awert/celery/worker.pid'
ExecReload=/bin/sh -c '/home/awert/checker_f/checker_e/bin/celery multi restart w1 -A checker_p -l info --pidfile=/home/awert/celery/worker.pid --logfile=/home/awert/celery/sworker.log --time-limit=21600 -E -S django'
[Install]
WantedBy=multi-user.target
[Unit]
Description=Celery beat
PartOf=celery.service
[Service]
User=awert
PermissionsStartOnly=true
ExecStart=/bin/sh -c '/home/awert/checker_f/checker_e/bin/celery beat -A checker_p -l debug --pidfile=/home/awert/celery/beat.pid --logfile=/home/awert/celery/beat.log --workdir=/home/awert/checker_f/'
Restart=on-failure
[Install]
WantedBy=multi-user.target
据我所知,celebeat承认计划任务:
[2017-08-24 12:31:42,242: INFO/MainProcess] beat: Starting...
[2017-08-24 12:31:42,243: DEBUG/MainProcess] DatabaseScheduler: initial read
[2017-08-24 12:31:42,243: INFO/MainProcess] Writing entries...
[2017-08-24 12:31:42,272: DEBUG/MainProcess] DatabaseScheduler: Fetching database schedule
[2017-08-24 12:31:42,286: DEBUG/MainProcess] Current schedule:
<ModelEntry: Sanity sanity_check(*[], **{}) <crontab: */2 * * * * (m/h/d/dM/MY)>>
<ModelEntry: celery.backend_cleanup celery.backend_cleanup(*[], **{}) <crontab: 0 4 * * * (m/h/d/dM/MY)>>
[2017-08-24 12:31:42,326: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2017-08-24 12:31:42,331: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.
[2017-08-24 12:31:47,337: DEBUG/MainProcess] beat: Synchronizing schedule...
[2017-08-24 12:31:47,337: INFO/MainProcess] Writing entries...
[2017-08-24 12:31:47,342: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.
之后只有
[2017-08-24 12:34:42,624: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.
[2017-08-24 12:34:47,630: DEBUG/MainProcess] beat: Synchronizing schedule...
[2017-08-24 12:34:47,631: INFO/MainProcess] Writing entries...
但是sanity_check任务永远不会运行。 celerybeat.service与文档显示的不同,但是对我有用。
有什么建议吗?
UPD:出于某种原因,任务被激活3次,间隔为2小时32分钟,而crontab设置为* / 2 * * *