Here is a puzzle I hope you can help me with. A client wants to send a welcome letter exactly 47 minutes after a document is uploaded via cgi script. I wrote a routine to send the letter, and then I attempted to use the Linux "at" command to execute it.
When this didn't work, I set up the following test in the /cgi-bin directory.
**** The bottom line is: The "at" command will not work when called by apache. Is there any way around this?
Thanks,
Rob Young
TEST FILES
---------------------------------------------------------------------------
$> cat test1.pl
#!/usr/bin/perl
#THIS IS A TEST OF THE "at" LINUX COMMAND WHEN CALLED FROM WITHIN APACHE
print "Content-type: text/html\n\n";
my @lt=localtime(time()+60);
my $cmd="echo '/path/to/test2.pl' | at $lt[2]:$lt[1]";
print $cmd;
system($cmd);
$> cat test2.pl
#!/usr/bin/perl
my $cmd="echo 'it ran!'>it_ran.txt";
system($cmd);
COMMAND LINE DEMONSTRATION
------------------------------------------------------------------
$> rm it_ran.txt
rm: cannot remove `it_ran.txt': No such file or directory
$> ./test1.pl
Content-type: text/html
echo '/path/to/test2.pl' | at 20:28job 55 at 2011-08-15 20:28
$> atq
55 2011-08-15 20:28 a ryoung
$> date
Mon Aug 15 20:27:11 CDT 2011
$> cat it_rat.txt
cat: it_rat.txt: No such file or directory
$> date
Mon Aug 15 20:28:01 CDT 2011
$> cat it_ran.txt
it ran!
APACHE DEMONSTRATION
------------------------------------------------------------------------------------------
Then I call the same script by browsing to http://www.MYSERVER.com/cgi-bin/test1.pl
[browser output:
echo '/path/to/test2.pl' | at 20:30
]
$> date
Mon Aug 15 20:30:40 CDT 2011
$> cat it_ran.txt
cat: it_ran.txt: No such file or directory