2012-07-03 16:30
浏览 68


i want a write a php script which can start , stop , enable and disable cron job. I want to create one interactive jquery page which will asynchronously send a request to php file which will stop , start , enable and disable the job

i have searched so many threads but still didn't get a proper way and i have looked following solutions and thread.

start stop cron job

i tried to implement the solution provided by J. Bruni but when i try to execute ./cron.php activate i am getting following errors

./cron.php: line 1: ?php: No such file or directory
./cron.php: line 3: =: command not found
./cron.php: line 4: =: command not found
./cron.php: line 6: syntax error near unexpected token `('
./cron.php: line 6: `$param    = isset( $argv[1] ) ? $argv[1] : '';'

i solved above error by #!/usr/bin/env php

i think my php file get stuck when following line comes

  shell_exec( 'export EDITOR="/home//www/cron.php on"; crontab -e' );

and i am getting following error

 Window size is too small for nano...crontab: "pico" exited with status 1

图片转代码服务由CSDN问答提供 功能建议

我想写一个php脚本,可以启动,停止,启用和禁用cron作业。 我想创建一个交互式jquery页面,它将异步发送请求到php文件,这将停止,启动,启用和禁用作业

我搜索了这么多线程但仍然没有 得到一个正确的方法,我已经看了下面的解决方案和线程。

start stop cron job

我试图实现J. Bruni提供的解决方案,但是当我尝试执行 时。 /cron.php 激活我收到以下错误

  ./ cron.php:第1行:?php:没有这样的文件或目录
./cron  .php:第3行:=:命令未找到
 ./  cron.php:第6行:`$ param = isset($ argv [1])?$ argv [1]:'';'

我在上面解决了 错误#!/ usr / bin / env php


  shell_exec('export EDITOR =“/ home // www / cron.php on”;  crontab -e'); 


 窗口大小对于nano来说太小了 ... crontab:“pico”退出状态1 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanqi6274 2012-07-03 16:41

    First of all, if you want to execute a php file, on the first line write always write

    ` #!/usr/bin/env php`

    Then :

    1. give the file execution privileges

      chmod +x file.php

      Then execute it, as follows


    Or :

    1. execute it using php command

      php file.php

    解决 无用
    打赏 举报

相关推荐 更多相似问题