run php script once in a week

Deadly 提交于 2019-12-10 20:32:33

问题


every Monday I need to empty few fields of a MYSQL database I have

Firstly I thought about using a cron job, but my Web Hosting provider (fatcow.com) doesn't support neither SSH or Command Lines into shared servers.

I've also thought about checking the date() to see if it's monday and perform something, but then I need to run that specific page continuously and I've read that it's a problem.

So now I ask you, how can I do this ?

Thanks for answers


回答1:


If your job can reached via a URL, you might try to sign up with a free crontab service like onlinecronjobs.com




回答2:


If you have access to any other server that will allow to run cron job, you can create a php file there and run your url to be executed from that server. Use curl, wget or streams to do this.




回答3:


If you have access to any other servers that do allow cron, since FatCow doesn't, you could make a cron job that calls wget on a php script on your server -- eg wget http://example.com/fake-cron.php




回答4:


Should be possible to setup some kind of job in mysql itself. Not 100% sure about it, but read up on

CREATE EVENT something ON SCHEDULE

And maybe you find a way to do it from MySQL instead of PHP. Sorry I can't be of more help, just thought you'd might want to check it out

MySQL Events




回答5:


If you have access to another server (with ssh) just add a cron job on it that hit your php script once a week. Unfortunately i don't think there is a way to do it directly on your php script.




回答6:


What's the control panel for that host? cPanel? If so, cPanel almost always has a Cron tool under Advanced. Could also potentially do an exec or system command from a php script to set up the Cronjob (unless that's what you mean by not supporting 'command lines').



来源:https://stackoverflow.com/questions/4583930/run-php-script-once-in-a-week

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!