-1

I have a job which created by PHP script running as www (nginx)

31      2014-06-09 19:08 a www

After the time passed, the job is executed but nothing happens.

But if i run it as a root,

32      2014-06-09 19:09 a root

the job is executed and i can get the result.

Any idea how to allow www run the at job?

EDIT: This is how my php script executing at command

$command = 'echo "/usr/bin/php -q /home/wwwroot/cron/poster.php 8137660219700061402317686 1" | at now + 1 minute';

shell_exec($command);

There will be a job listed, created by www

atq -c 48

More info regarding the at job,

48      2014-06-09 21:08 a www

[root@914K7 ~]# at -c 48
#!/bin/sh
# atrun uid=501 gid=501
# mail www 0
umask 22
USER=www; export USER
PWD=/home/wwwroot/ajax; export PWD
SHLVL=1; export SHLVL
HOME=/home/www; export HOME
cd /home/wwwroot/ajax || {
     echo 'Execution directory inaccessible' >&2
     exit 1
}
${SHELL:-/bin/sh} << 'marcinDELIMITER509e6acf'
/usr/bin/php -q /home/wwwroot/cron/poster.php 81376602197000614023176 1

marcinDELIMITER509e6acf

But after time passed, the job is gone meaning it has been executed, but I dont receive any output from the script.

If I manually create at job through command line as a root, I'm getting output after the job is executed.

9
  • 1
    possible duplicate of how do i perform root actions from non-root account?
    – MadHatter
    Jun 9, 2014 at 11:28
  • @MadHatter Tried it but still now working.
    – Syed
    Jun 9, 2014 at 11:59
  • 1
    Either you mean it's now working, in which case, good! Or you mean it's not working, in which case I suspect the accuracy of your typing generally. SHOW us what you've done - edit the sudoers entry into your question, plus the modified line of PHP code that invokes sudo, and the results of atq after you've submitted a job. Just telling us what you think you've done is no help, because you may well not have done what you think.
    – MadHatter
    Jun 9, 2014 at 12:08
  • Sorry i meant its not working. I have append more info.
    – Syed
    Jun 9, 2014 at 13:11
  • @Syed Look at the logfiles. Shortly after the at job has executed, you can type ls -lart /var/log to see which file it has logged to. On Ubuntu the logfile to look at is /var/log/syslog.
    – kasperd
    Jun 9, 2014 at 13:59

1 Answer 1

0

You seem to have provided output which looks as if it might be a process - but you didn't tell us what this information is nor where you get it from. You state the job is executed hence clearly your php script is able to invoke 'at'. It might not be doing what you expect, bt you have provided no details of what the script is intended to do, nor what resources it requires to acheive that.

The problem is in you script - not it's invocation via 'at'.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .