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!