Use PHP to create, edit and delete crontab jobs?

前端 未结 12 1268
余生分开走
余生分开走 2020-11-22 06:54

Is it possible to use PHP to create, edit and delete crontab jobs?

I know how to list the current crontab jobs of the Apache user:

$output = shell_ex         


        
12条回答
  •  有刺的猬
    2020-11-22 06:59

    The easiest way is to use the shell_exec command to execute a bash script, passing in the values as parameters. From there, you can manipulate crontabs like you would in any other non-interactive script, and also ensure that you have the correct permissions by using sudo etc.

    See this, Crontab without crontab -e, for more info.

提交回复
热议问题