0

I'm using PHP to perform a CRON task. It runs as root.

For example:

php -f /my-cron-folder/my-cron-task.php

Under some circumstances, I want to restart the server's firewall (CSF+LFD) at the end of the script running.

The server has exec and system disabled for security.

I could in PHP create or delete a file to act as a trigger for a subsequent CRON task to act on the existence of, or not if it does not exist.

But it's really not a very elegant way of going about it especially because I can't know how long the PHP task will take to complete (it will vary) so I'll have to guess how long after it runs to launch the file existence check.

Any better suggestions?

methode
  • 5,348
  • 2
  • 31
  • 42
Claud
  • 937
  • 1
  • 12
  • 27
  • You can use [shell_exec](http://php.net/manual/en/function.shell-exec.php) – Alex Jun 29 '15 at 12:11
  • When you php script return it could send a status code (with `exit($status_code)`) and depending of the value, you cron could choose to restart the server (with chain command: `php -f cron.php && i_need_to_restart.sh` – Cyrbil Jun 29 '15 at 12:20
  • Alex: Warning: shell_exec() has been disabled for security reasons :( – Claud Jun 29 '15 at 13:00
  • cyrbil - thanks that looks like a possibility! – Claud Jun 29 '15 at 13:01

0 Answers0