How to set a crontab using php?

谁都会走 提交于 2019-12-04 15:01:43

Are you running crontab -l as the same user as the web server is running under? Otherwise you won't see its cronjobs.

Apache generally isn't going to be able to muck around with the main crontab. However, each user has a crontab as well, and it's quite likely that your code above is setting apache's crontab (or the crontab for whatever user your site runs as).

Try crontab -u apache -l, or replace apache with whatever user your site runs as, and see if the entries you set are there.

You generally have to be root to set the crontab, and it's unlike that php is running as root, in which case you're out of luck.

Edit: Not completely out of luck. See the link in Sebastian's comment above.

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