• Welcome to LiuJason's Blog!

使用service替代crontab执行小于1分钟间隔的定时任务

Linux笔记 Jason 4 years ago (2020-01-21) 963 Views 0 Comments QR code of this page

服务需要为了实现验证短信的异步发送,需要每隔10秒执行发送任务,但是cron显然实现不了。因此需要一个替代品——service

新增一个linux service,包含两个文件:

文件1:/etc/systemd/system/whmcs-sms.service

[Unit]
Description=Send WHMCS SMS
[Service]
User=www
ExecStart=/usr/bin/php -q /www/wwwroot/cloudraft-whmcs/modules/addons/sms_center/cron.php

文件2:/etc/systemd/system/whmcs-sms.timer

[Unit]
Description=Send WHMCS SMS every 10 seconds
[Timer]
OnBootSec=10
OnUnitActiveSec=10
AccuracySec=1ms
[Install]
WantedBy=timers.target

This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/497.html
Like (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址