mmmbaileys mmmbaileys - 1 year ago 136
PHP Question

Bash script to run php script

I have a php script that I want to be run using a bash script, so I can use Cron to run the php script every minute or so.

As far as I'm aware I need to create the bash script to handle the php script which will then allow me to use the Cron tool/timer.

So far I was told I need to put:


at the start of my php script. Im not sure what to do from here...

Any advice? Thanks.

Answer Source

If you have PHP installed as a command line tool (try issuing php to the terminal and see if it works), your shebang (#!) line needs to look like this:


Put that at the top of your script, make it executable (chmod +x myscript.php), and make a Cron job to execute that script (same way you'd execute a bash script).

You can also use php myscript.php.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download