At command for Linux job not working from php

I have a script .sh with a curl command in it:

curl --digest "http://xxxxxxx.xxx/mail.php?email=xxxx@xxx.xx";

from terminal this works good :
./script.sh //(mail arrives in my box)

from php this works good:
shell_exec('./phpsc.sh'); // (mail arrives in my box)

from terminal this works good:
at -f phpsc.sh now + 5 minute // (job created, mail arrives in my box after 5 minutes)

from php this won't work:
shell_exec('at -f phpsc.sh now + 5 minute'); //:frowning: :frowning:

even when I put at command in script and run the script from php the at command it will be ignored :frowning:

What's in the log.txt when you execute this?

shell_exec('at -f phpsc.sh now + 5 minute >/tmp/log.txt 2>&1'); 

...and i think correctly it is called +5 minutes (s at the end).

1 Like

By "from PHP" you really mean "when run by the web server through CGI", yes?

Your web server will likely be running it as the apache user and group, which may not be in at.allow, and may not have write-access to the folders you wanted.

1 Like

from php:
this works shell_exec('./phpsc.sh');
this not shell_exec('at -f phpsc.sh now + 5 minute')

the same code from terminal works fine on both:
this works ./phpsc.sh'
this works also at -f phpsc.sh now + 5 minute'

sorry for my english anyone have explanation :frowning: :frowning: :frowning: :frowning: :confused: :confused:

Please answer my question.

1 Like

yes from a browser, php and apache are installed on my VPS debian 7

at comand not allowd ?? how can i slove that sir :confused:

---------- Post updated at 03:03 PM ---------- Previous update was at 02:58 PM ----------

i have cheked php.ini and not found 'at' on the not allowed comand list :confused:

Hi extra,

if you execute the command I wrote before, you'll get an error message, which will help you to figure out your problem.

Run the command stomp gave you and tell us what it says.

oh sorry STOMP yes i tried but no file exist in /tmp/ or am i wrong on somethings ?

'at' cammand always ignored from php even when i put 'at' comand in script and run it from php at camand ignored and the reste of code works,

one more time sorry for my english

Obviously something is wrong....

You can check file permissions. Maybe your script has no access to /tmp. Please post the output of the following commands:

ls -ld /
ls -la /tmp

Maybe you typed in my command not 100% exact as I typed it here? I suggest you to double check it and copy&paste it here in. Maybe there's error.
Please always use code tags for code, input files, or command output. That's this icon:

...and as a very likely issue that will be present here: please use absolute path names! Instead of this...

shell_exec('at -f phpsc.sh now + 5 minute >/tmp/log.txt 2>&1');

...use this...

 shell_exec('/usr/bin/at -f /path/to/your/script/phpsc.sh now + 5 minute >/tmp/log.txt 2>&1');

Have a look at your php.ini too. Especially at the setting disable_functions. Maybe shell_exec is listed there?

1 Like

Ooh Thank you bro this realy helps me, here is what i get in LOG.TEXT:

from terminal:

warning: commands will be executed using /bin/sh
job 56 at Thu Jun  9 23:34:00 2016

from php (shell_exec):

You do not have permission to use at.

:slight_smile: :confused::confused:

---------- Post updated at 05:44 PM ---------- Previous update was at 05:33 PM ----------

in /etc/at.deny i have this user list or i don't know what, the permission probleme come frome here i think ???

alias
backup
bin
daemon
ftp
games
gnats
guest
irc
lp
mail
man
nobody
operator
proxy
qmaild
qmaill
qmailp
qmailq
qmailr
qmails
sync
sys
www-data

There's a manual page for that file...

man at.deny
1 Like

i have find the solution thank you guys,

i removed www-data from /etc/at.deny and now 'at' comand works fine from php (sell_exec)

i hope this topic help another one :slight_smile:

1 Like

You looked at the wrong place. See http://linux.die.net/man/5/at.allow .