dsb53973 2015-04-27 08:12
浏览 33
已采纳

如何从我的PHP应用程序安全地创建Cron作业?

I am building a web app (using PHP) which needs to offer the end user the functionality to receive an update every x hours, between a range of dates. I know you can create a cron job using "shell". However, I have disabled shell in php.ini to secure my server, in the event of any malicious code finding its way on to my server. Is there a way to securely create a cron job from my app without resorting to using system commands?

Edit

In response to Halayem's comment for further clarification. A registered user in my system may set up a repeating task in my app that will send an SMS message to their mobile number every X Hours where X is a user defined time. I wish to build a secure way of implementing a cron job to automatically send the message every X Hours when the user creates the task.

  • 写回答

1条回答 默认 最新

  • dougang7521 2015-04-27 08:43
    关注

    You don't ever dynamically create new cron jobs from code, that's madness. What you do is you set up one cron job explicitly which checks every so often if there's something to do, and you keep a database of tasks that the cron job should do.

    Simple example: if there's an option for your customers to receive a mail every hour, then you set up a cron job which checks your database every hour for which customers opted into receiving a mail and then sends those mails.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元