douao2000 2015-08-08 16:37
浏览 47

为数据库日期时间设置cron作业[关闭]

What is the best way to set a cron job for a datetime that is saved in a database? I have never used cron jobs before so I am unfamiliar with them. I have done some research on it and the only way I see this happening is if I set the cron job at a 30 minute interval then make sure the event times fall on the hour or half hour mark. But even then the job would be running the code even if there is no event.

  • 写回答

1条回答 默认 最新

  • duanshan1856 2015-08-08 16:51
    关注

    Depending on the use case and requirements of your application, you can use a shorter interval as well. Unless of course you want to batch-process the jobs on the hour / half hour mark.

    I wouldn't worry about the overhead of the code itself triggered by the cron. As long as it just peeks at the database to see if there's an event to run, it should finish quickly if there's no new event.

    A few tips if you've never used cron jobs before. Make sure that:

    • The script you're calling is reporting errors (try it out first by invoking it via the shell).
    • You're not discarding the output of the script by e.g. redirecting to dev/null.
    • You've set yourself as the recipient for cron notification emails. So if it fails for any reason, you'll have something to hold onto.
    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制