Jump to content

create cron job with php


Craig Hopson

Recommended Posts

hi guys im stuck again this is what i have so far but it wont work

<?php$data = '0 0 * * * /usr/local/bin/php $HOME/public_html/run_this_script.php';file_put_contents('cron.txt', $data, FILE_APPEND);exec("/usr/bin/crontab cron.txt", $output, $return);if($return === 0) {echo 'Cron Successful';} else {echo 'Cron Unsuccessful';}echo "<br />\nOutput:<br /><br />";var_dump($output);echo "<br /><br />done!";?>

Link to comment
Share on other sites

Got it to work now

file_put_contents('crontab.txt','0 * * * * php /home/chsitesc/delete1.php'.PHP_EOL);echo exec('crontab crontab.txt');$output = exec('crontab -l');echo $output;$myFile = "crontab.txt";unlink($myFile);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...