Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot setup cron job.

Status
Not open for further replies.

pbayly

Programmer
Oct 6, 2009
1
0
0
IE
I am having trouble setting up a cron job using the command line.

I have a website which must run a once off Cron Job at a time designated by the users input.

******************************************************
// $expirydatetime is a timestamp;
$min = date("i",$expirydatetime);
$hour = date("H",$expirydatetime);
$day = date("j",$expirydatetime);
$month = date("n",$expirydatetime);
$dow = date("N",$expirydatetime);

$commandline_expression = $min." ".$hour." ".$day." ".$month." ".$dow." /var/echo "<br />".$commandline_expression."<br />";
//exec($commandline_expression);
******************************************************

Unfortunately I cannot get the command line expression to work in the command line when logged in under Root.

I get the following response when pasted into the SSH command line.


******************************************************
-bash: 06: command not found
******************************************************

Please help, any assistance is greatly appreciated.
 

That looks like a Perl program. If so, then you need to run it the perl command.

 
Actually, I believe its PHP, which does look a lot like perl.
Three things. 1 - What is in $commandline_expression?, 2 - do you need to to echo (or print) the value to a server variable in order to get it to execute to the command line? It looks to me like the script would attempt to print this to the web page. 3 - Do you have a proper script referred to by $commandline_expression (e.g. it begins with #!/usr/bin/sh) AND is it set as an executable script?


 
It looks to me like $commandline_expression is actually constructed in the format of a crontab line, therefore you'd expect it to be added to the user's crontab, not executed. But then it is being printed out between some HTML tags, so this is a bit of a confusing mess really! To further confuse things the autosend.php "script" is being called with some HTTP GET style parameters, which won't work from the shell command-line anyway, so even if it was added to crontab correctly I don't see how it would work.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top