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.

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

报告相同问题?

悬赏问题

  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'
  • ¥15 vue+element项目中多tag时,切换Tab时iframe套第三方html页面需要实现不刷新
  • ¥50 深度强化学习解决能源调度问题
  • ¥15 一道计算机组成原理问题