0

Small fast question: Is possible to create cronjob using PHP if "safe mode" is "on"?

I foollow this thread for creating and updating cronjobs using php: Use PHP to create, edit and delete crontab jobs?

Some shared hosting has default settings with enabled php safe mode. If i use my script using "exec()" function, apllication will down.

Community
  • 1
  • 1
drozdo
  • 89
  • 10

2 Answers2

0

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)

The workaround is to try to do the task you need in a single .php file and upload it to the server. Then, in a machine you control, create a cronjob to call this .php file.

Remember, I STRONGLY DO NOT RECOMMEND using this workaround, but if it's strictly necessary and you don't have another option...

barbarity
  • 2,222
  • 1
  • 17
  • 26
0

I have a doubt that on all shared hosting you will be able to use cron (as local service) at all. Instead you can use on of the free web cron solutions that can help you run recurrent tasks, like http://www.mywebcron.com/

Or if you have a own normal server somewhere you can invoke tasks with curl. The thread that you mentioned has some examples that you can use. It would be better and safer.

wisp
  • 436
  • 5
  • 7