简体   繁体   English

在安全模式下使用php管理cronjobs

[英]manage cronjobs using php in safemode

Small fast question: Is possible to create cronjob using PHP if "safe mode" is "on"? 一个小小的快速问题: 如果“安全模式”为“开”,是否可以使用PHP创建cronjob?

I foollow this thread for creating and updating cronjobs using php: Use PHP to create, edit and delete crontab jobs? 我使用此线程来使用php创建和更新cronjobs: 使用PHP创建,编辑和删除crontab作业?

Some shared hosting has default settings with enabled php safe mode. 一些共享主机具有启用了php安全模式的默认设置。 If i use my script using "exec()" function, apllication will down. 如果我使用“ exec()”函数使用脚本,则应用程序将关闭。

Short answer: Safe mode ON does not allow that. 简短的回答:安全模式打开不允许这样做。

But, there is a workaround which I don't recommend due the problems it may cause. 但是,由于它可能引起的问题,我不建议您使用一种解决方法。 (I would recommend you to buy a VPS instead or change your hosting) (我建议您改为购买VPS或更改主机)

The workaround is to try to do the task you need in a single .php file and upload it to the server. 解决方法是尝试在单个.php文件中完成所需的任务,然后将其上传到服务器。 Then, in a machine you control, create a cronjob to call this .php file. 然后,在您控制的计算机上,创建一个cronjob来调用此.php文件。

Remember, I STRONGLY DO NOT RECOMMEND using this workaround, but if it's strictly necessary and you don't have another option... 请记住,我强烈不建议您使用此替代方法,但是如果绝对必要,并且您没有其他选择...

I have a doubt that on all shared hosting you will be able to use cron (as local service) at all. 我怀疑在所有共享主机上,您是否都可以使用cron(作为本地服务)。 Instead you can use on of the free web cron solutions that can help you run recurrent tasks, like http://www.mywebcron.com/ 相反,您可以使用免费的Web cron解决方案来帮助您运行重复任务,例如http://www.mywebcron.com/

Or if you have a own normal server somewhere you can invoke tasks with curl . 或者,如果您在某处拥有自己的普通服务器,则可以使用curl调用任务。 The thread that you mentioned has some examples that you can use. 您提到的线程具有一些可以使用的示例。 It would be better and safer. 这样会更好,更安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM