I want to add a cron job in my Raspberry to execute a task every five minutes. So I do in the terminal:
crontab -e
and then add at the file:
*/1 * * * * /usr/bin/php myscript path.
The script is something very simple. just to try if it works:
<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = date("l jS \of F Y h:i:s A") . "<br>";;
fwrite($myfile, $txt);
fclose($myfile);
?>
The problem is that the date isn't updated, so the cron job doesn't work. Any idea of the problem ?
UPDATE
This what I got, when I execute crobtab -e
GNU nano 2.2.6 File: /tmp/crontab.3IXg0z/crontab
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /usr/bin/php /full/path/myscript.php
.../php myscript path
implies that your php code file is calledmyscript
, and you're passing inpath
as a command-line argument.