0

I was running a php script in background, and what I tried:

shell_exec('nohup php C:\wamp\www\Management_software\application\views\testcron.php  > /dev/null & echo $!');

This is working fine when I opened up the command prompt(cmd) and tried:

php C:\wamp\www\Management_software\application\views\testcron.php

But this is not working from the php page, how to solve this or any other techniques or what are the modifications I have to make ?

2
  • Are you getting any error??? Commented Dec 30, 2013 at 7:48
  • Nope am getting nothing in my php page , But in cmd am getting the output Commented Dec 30, 2013 at 7:52

1 Answer 1

2

This might help you debug the problem. exec can take 3 arguments and those help in identifying what's going on.

Try with

exec('nohup php C:\wamp\www\Management_software\application\views\testcron.php  > /dev/null & echo $!', $op, $er); 
echo $er;` 

and see what gets printed on the page. If the value of $er is greater than 0, then something is wrong.

For list of exit codes, refer this list

Sign up to request clarification or add additional context in comments.

5 Comments

The value of $er is 0
That means the command executed successfully. Whatever was written in testcron.php was completed. So if it had, for example say, an insertion into the database you could verify it by looking it up in the table.
Yeah i have an insert command ,But its not working actually .
Well i have to add anything in php.ini , inorder to work , 'exec' and 'shell_exec' functions ?
Well It worked , there was no writing permission on the file !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.