mikemike27 Posted June 27, 2012 Share Posted June 27, 2012 I have a webpage form that requires a date and time to be submitted. When it's submitted I need the back-end to run a script at the time and date specified. Have you ever needed to do something like this? I've tried the exec() function with an at command inside. It won't work. I have no idea why and there doesn't seem to be a lot of advice on google about this. so either no one has ever had a problem with it before or no one has ever tried because there is a much simplier way. I've also tried a shell script but I didn't really understand what I was typing. It was mostly a guess. Here it is; $fileOutput = "#!/bin/bash\n\n"; $fileOutput.= "php ".$doc_root."/byot/author/publish_tables.php jobid=".$jobid." ".$result." catid=".$catid." docroot=".$doc_root; $myFile = $doc_root."/byot/author/publishjob".$jobid.".sh"; $fh = fopen($myFile, 'w') or die("can't open file"); fwrite($fh, $fileOutput); fclose($fh); shell_exec('chmod a+x '.$myFile); $fileOutput = "#!/bin/bash\n\n"; $fileOutput.= "at $publishTime $publishday.$publishmonth.$publishyear -f $myFile"; $runfile = $doc_root."/byot/author/runat".$jobid.".sh"; $fh = fopen($runfile, 'w') or die("can't open file"); fwrite($fh, $fileOutput); fclose($fh); shell_exec('chmod a+x '.$runfile); exec($runfile); Any tips or advice greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/264865-what-is-the-best-method-for-running-scheduled-jobs-in-php/ Share on other sites More sharing options...
trq Posted June 27, 2012 Share Posted June 27, 2012 Your best bet would be to store the daytime in a database, then have a corn job run every minute that checks this database to see if it needs to execute your task. Link to comment https://forums.phpfreaks.com/topic/264865-what-is-the-best-method-for-running-scheduled-jobs-in-php/#findComment-1357411 Share on other sites More sharing options...
xyph Posted June 27, 2012 Share Posted June 27, 2012 Mmm... corn job... *drools* CRON is what you're looking for Link to comment https://forums.phpfreaks.com/topic/264865-what-is-the-best-method-for-running-scheduled-jobs-in-php/#findComment-1357442 Share on other sites More sharing options...
trq Posted June 28, 2012 Share Posted June 28, 2012 Yeah, the predictable text on my phone can be a pain. there will prob be a few similar posts over the next week or so as I'm off work and moving house. no Adsl for me. Link to comment https://forums.phpfreaks.com/topic/264865-what-is-the-best-method-for-running-scheduled-jobs-in-php/#findComment-1357588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.