Cron job issues

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
richardlaw
Forum Newbie
Posts: 2
Joined: Sun Oct 12, 2008 7:19 pm

Cron job issues

Post by richardlaw »

Hi guys, in the next post ill post up the php code, but for now ill give you the description of the problem.

Ok what we are trying to do, is write out a cron job that executes start.sh immediately and then closes it 1 hour and 25 minutes later.

the code writes up 2 con files that executable reads for the settings, now we run it using a URL like http://test/index.php?servername=blah&port=blah

now when we run it as it stands, it writes those two con files with no issues, and if i run start.sh manually it works with the correct settings, its the cron part of the script that seems to be in error as it doesnt even seem to be creating a cron job to run.

script coding in the next post:
richardlaw
Forum Newbie
Posts: 2
Joined: Sun Oct 12, 2008 7:19 pm

Re: Cron job issues

Post by richardlaw »

****note**** the username has been edited out for security purposes

include('class.crontab.php');

$crontab=new crontab("/home/username/", "cron");
$crontab->setDateParams(date("i"), date("H"), date("d"), date("m"), "*");
$crontab->setCommand("/home/username/servers/1/bf2142/start.sh");
$crontab->saveCronFile();
$crontab->addToCrontab();
$crontab->destroyFilePoint();

/*$crontab=new crontab("/home/username/", "cron");
$crontab->setDateParams((date("i") + 25), (date("H") + 1), date("d"), date("m"), "*");
$crontab->setCommand("php -f /home/username/public_html/kill.php");
$crontab->saveCronFile();
$crontab->addToCrontab();
$crontab->destroyFilePoint();*/

echo shell_exec("cd /home/username/servers/1/bf2142/");
echo shell_exec("./start.sh");
} else {
echo "The file is not writable";
}
Post Reply