1

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.

2 Answers2

1

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.
Safado
  • 4,726
  • 7
  • 35
  • 53
  • 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
1

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

zerodeux
  • 656
  • 4
  • 6