
Originally Posted by
End User
PHP Code:
<?
crontab_set('*','*','*','*','*');
function crontab_set ($min, $hour, $monthDay, $monthNum, $weekDay)
{
$command = "$min $hour $monthDay $monthNum $weekDay /usr/local/bin/php -f /home/egypthol/public_html/snd2.php";
//echo $command;
$cron_file = "Feed_cron";
// check for cron/Feed_cron file. If it doesn't exist create it.
// you must create the file from the browser to associate the proper group
if (file_exists($cron_file))
{ // if it exists, write new command
$open = fopen($cron_file, "w"); // This overwrites current line
fwrite($open, $command);
fclose($open);
// this will reinstate your Cron job
exec("crontab /home/egypthol/public_html/cron/Feed_cron") or die ("Error");
}
else
{ // if it Doesn't exist, Create it then write command
touch($cron_file); // create the file, Directory "cron" must be writeable
chmod($cron_file, 0777); // make new file writeable
$open = fopen($cron_file, "w");
fwrite($open, $command);
fclose($open);
// start the cron job!
exec("crontab /home/egypthol/public_html/cron/Feed_cron")
or die ("Error");
}
}
?>
this is my code... and it makes the file Feed_cron and make inside it the commad
but there is an error in the exec line coz when the page is loaded the die message ("error") appears.. so i found that the error is in the execute line
could u plz help me in solving this problem
Bookmarks