Jump to content

Recommended Posts

If the script you want executed is a php script it should contain a shebang line on the very first line. This lets the shell know what program should execute your script. eg;

 

#/usr/bin/php
<?php

// some php script

?>

 

You can now simply put;

 

10 * * * * /path/to/your/script.php

 

in your crontab. Otherwise, without the shebang, you need to actually specify what program to use to execute your script within the crontab entry;

 

10 * * * * /usr/bin/php /path/to/your/script.php

I am still confused, do I need to add a certain piece of code to the file I want to be executed?

 

I think your confusion here stems from the fact that you're only used to seeing PHP run on the web. PHP is a scripting language just like any other. If you stick it in a file and mark it executable you can pass it to the PHP CLI interpreter instead of having it called by apache or whatever webserver you're using. The procedure for setting up the cron job is exactly the same whether it's a shell script, python script, perl script, PHP script, or any other executable.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.