1

I have never added a cron job and am not much use with shell either... My chosen cron directory is /etc/cron.daily/

all I need my script to do is run a php file daily. I would be nice if it ran at 11:00 AM.

Is this all I need for the 'script'?:

#!/bin/sh php myphppage.php 

how (what command) do I 'submit' the script to the cron.daily?

Sincere thanks!

1
  • 1
    You don't need a shell script at all. You can just run it directly. Commented May 29, 2015 at 20:23

1 Answer 1

1

You should setup a cron task by yourself instead.

Just type crontab -e to edit the crontab and add the following to run your script every days at 11:00 AM :

00 11 * * * /path/to/script.sh 

Or run your PHP script directly from crontab :

00 11 * * * /usr/bin/php /path/to/myphppage.php 

Save and exit.


If you want to use an external script call (first sample i used with script.sh), you should specify full path to binaries/script within your shell script :

#!/bin/sh /usr/bin/php /path/to/myphppage.php 

As a side note, using the appropriate shebang in your PHP script you don't even need to specify the program to use to run your script. Add the following at the beginning of your PHP file :

#!/usr/bin/php 

Then your crontab will just look like this :

00 11 * * * /path/to/myphppage.php 
2
  • I am going to update my question with one new thing if that's ok... Commented May 29, 2015 at 20:34
  • actually figured it out. Thanks again! really appreciate it. Commented May 29, 2015 at 20:43

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.