I have a zendframework project for which i need to run a script periodically to upload the content of a folder and another do download. The script itself is ready but I am strug
First, make sure you have this at the top of your PHP script (followed by the opening PHP tag):
#!/usr/bin/php
Second, make sure the permissions are right. For example, if you create the cron job under root, then I believe root will try to run the PHP script if I'm not mistaken. Likewise, if you create the cron job under a different user, they better have the correct permissions to the PHP script.
For example (note, depending on your server environment, the permissions will need to be adjusted accordingly. e.g. this is just a hypothetical example)
$ chmod 755 script.php
$ chown userThatRunsScriptWithCron script.php
If you want to see the current cron jobs for the current user you're logged in as, do this:
$ crontab -l
Or, if your cron job is set up in one of the folders such as cron.hourly, cron.weekly, etc, then you can view which user "owns" those jobs by doing this:
$ cat /etc/crontab
Then at the bottom of the file you'll see them.
Now, to setup the cron job run this command to open the editor:
$ crontab -e
Then enter your values:
1 2 3 4 5 php /path/to/script.php
Now save and close the file. Obviously, you're going to change 1 2 3 4 5
to something real and meaningful. For more information about that see this page (google "cron").
Disclaimer: I am not a cron master by any means. Please correct me on any of this if I'm wrong.