Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to use a PHP script to create at jobs, but when it comes time to execute the jobs, nothing seems to be happening. I've tried to output any errors to log files, but have had no luck. It seems obvious that it's a permissions issue, because when I set apache to run as my personal user, everything works fine. However, when I exec wget directly from PHP, everything works fine so it seems that apache has the correct permissions to use it. The problem appears to be when using at in conjunction with apache. So I need to find a way to make this work with apache running as its own user.

Here is the command I'm using:

echo "wget -qO- http://example.com/" | at now + 1 minute 2>&1

Any ideas?

EDIT: Apache can create the at jobs, it just seems that when they execute nothing is happening.

share|improve this question
1  
This is almost certainly the wrong way to do it. I've no idea what the right one is, though. –  Tom O'Connor Jun 25 '12 at 14:41
    
when I try to run the wget command above on my site (just the wget bit ie. wget -q0- mydomain.com/"; ) I'm gettin errors... –  gyre Jun 25 '12 at 15:04
    
wrote it out wrong, it should be -qO-, with an O not a zero –  Alex Padgett Jun 25 '12 at 15:12

2 Answers 2

Did you check to see if the apache user is in the at.allow file? Per the man page...

       The  /etc/at.allow and /etc/at.deny files determine which user can sub-
   mit commands for later execution via at(1) or batch(1).

   The format of the files is a list  of  usernames,  one  on  each  line.
   Whitespace is not permitted.

   The superuser may always use at.

   If  the  file  /etc/at.allow exists, only usernames mentioned in it are
   allowed to use at.

   If /etc/at.allow does not exist, /etc/at.deny is checked.
share|improve this answer
    
at.allow does not exist, but at.deny is empty. Apache can create the at jobs, it just seems that when they execute nothing is happening. –  Alex Padgett Jun 25 '12 at 14:45
    
I have a feeling I've done this before.. but it wasn't for apache or php.. I can't remember what it was. –  Tom O'Connor Jun 25 '12 at 14:45

The problem is similar to that of cron : your job execute in a minimal environment (think PATH=/bin:/usr/bin and 2 or 3 things) and with nothing attached to its standard input and outputs.

First make sure your Apache account as a working shell (and not /bin/false), because 'at' will use this shell to run your jobspec.

Then try this more specific snippet :

echo "/usr/bin/wget -qO- http://example.com/ >/tmp/example.com 2>/tmp/example.com.error" | at now + 1 minute

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.