1

I am using PHP exec command for execution of job on webserver. Initially It start executing job but was interrupted before completion of the job. While same job is running fine through SSH command.( user don't have sudo power) following is my code:

 ob_start();
 $pid=system("sh fold.sh $argument1 >/dev/null & echo $!");
 ob_end_clean();

I also tried few methods to check the error but could not succeed.

I used test.txt and 2>&1 or 2>error.txt instead of /dev/null but not working Command(exec in php) is working only when I am using /dev/null. So I don't know where is the error. Why it is interrupted in between.

Any Idea what could be the problem?

normal time for job on SSH prompt(user:abc) : 14-20 hrs interruption time through php(user:daemon): 1-2 hrs

  • Why it start executing job at starting and after 60-70 minutes suddenly interrupted. and even the same script is working on ssh(without using sudo user). – Amarinder Singh Thind Jul 29 '15 at 04:59

1 Answers1

0

Add sudo permission to www-data user

www-data ALL=(ALL) NOPASSWD: fold.sh

  • Is it necessary? Right now I don't have sudo power. If yes, Then I have to ask my server admin. – Amarinder Singh Thind Jul 28 '15 at 12:13
  • Yes, The Apache’s user www-data need to be granted privileges to execute certain applications using sudo. http://stackoverflow.com/questions/3166123/how-to-call-shell-script-from-php-that-requires-sudo http://unix.stackexchange.com/questions/115054/php-shell-exec-permission-on-linux-ubuntu – Ganesan Karuppasamy Jul 28 '15 at 12:19
  • Why it start executing job at starting and after 60-70 minutes suddenly interrupted. and even the same script is working on ssh(without using sudo user). – Amarinder Singh Thind Jul 29 '15 at 04:59