Reputation: 151
I'm trying to install this crontab:
*/1 * * * * /usr/bin/php /var/www/vhosts/mydomain.net/httpdocs/administrator/makeXML.php
In crontab there are others scripts installed.
In makeXML.php
I inserted a control to understand if crontab is executing:
#!/bin/sh
<?php
$test_file = "../xml_crontab.txt";
$fp = fopen($test_file, 'a');
fwrite($fp, "Last xml generation: ".date("Y-m-d H:i:s")."\n");
fclose($fp);
...
?>
I need to execute this script (makeXML.php
) every one minute. What I'm doing wrong?
Upvotes: 0
Views: 205
Reputation: 123618
You need to supply the absolute path to the file in your script.
Change the line:
$test_file = "../xml_crontab.txt";
to supply the absolute path to xml_crontab.txt
.
Remember that cron
isn't running in the same environment as you are and the script wouldn't be able to locate the file with relative pathname.
Upvotes: 3