pmzq Posted July 18, 2006 Share Posted July 18, 2006 Ok people here we go:I've been trying to get a certain .php file to execute a .sh file on my server.When I'm on the server in a shell and I axecute the following command:nohup /wwwroot/htdocs/test/ticker/tick.shThen the tick.sh file is executed and is running in the background which is what I want.Now my question is to run the same command, but I want to run it from a php file in on the server. Somewere in /wwwroot/htdocs/testI thought It would be easy to just do the following:exec("nohup /wwwroot/htdocs/test/ticker/tick_test.sh") ;Well yes it did NOT :o I've read lots of articles about this isue but can't seem to find a sollution.Is there a problem with my server do I need to login on the server first with a PHP script in order to execute such a command ?Hope to hear something soonGreetzz pMzQ, Link to comment https://forums.phpfreaks.com/topic/14978-exec-nohup-command/ Share on other sites More sharing options...
zq29 Posted July 19, 2006 Share Posted July 19, 2006 Have you tried adding the output parameter to the exec() function to see if it is spitting out any error messages? Link to comment https://forums.phpfreaks.com/topic/14978-exec-nohup-command/#findComment-60360 Share on other sites More sharing options...
pmzq Posted July 19, 2006 Author Share Posted July 19, 2006 If I knew how to add such a output to my command ? Can you give me an example ?( yes I am a noob :D )pMzQ, Link to comment https://forums.phpfreaks.com/topic/14978-exec-nohup-command/#findComment-60427 Share on other sites More sharing options...
zq29 Posted July 19, 2006 Share Posted July 19, 2006 [code=php:0]exec("nohup /wwwroot/htdocs/test/ticker/tick_test.sh",$output);echo "<pre>"; print_r($output); echo "</pre>";[/code]Check out [url=http://www.php.net/exec]the manual page for exec()[/url] for any further details regarding the workings of the function. Link to comment https://forums.phpfreaks.com/topic/14978-exec-nohup-command/#findComment-60511 Share on other sites More sharing options...
pmzq Posted July 19, 2006 Author Share Posted July 19, 2006 Ok I did the following:exec("nohup /wwwroot/htdocs/test/ticker/tick_test.sh",$output);echo "<pre>"; print_r($output); echo "</pre>";I've putt this command in a php file and when I open the file it keeps on loading untill forever!When I go into ssh with putty and I kill the tick_test.sh file by typing kill $pid number i received with pgrep tick_test.shthen when I go to the page that exectuted the file it returns the following:Array( [0] => *** wo jul 19 22:13:29 CEST 2006 *** [1] => *sleeping [2] => *** wo jul 19 22:13:29 CEST 2006 *** [3] => *sleeping [4] => *** wo jul 19 22:13:29 CEST 2006 *** [5] => *sleeping [6] => *** wo jul 19 22:13:29 CEST 2006 *** [7] => *sleepingetc etc etc..until[1166] => Quiting through clean_up [1167] => Quiting through clean_upthat's it ????I set the permission for the ticker directory to 777 so don't think that has anything to do with it does it ?Hoppe to hear from ya soon thnx!pMzQ,p.s. I tried also something else:Here is the code of the tick_test.sh file:trap clean_up EXIT SIGTERM SIGKILL SIGABRTfunction clean_up() { echo "Quiting through clean_up" rm ./ticker.run rm ./ticker.run.timer rm ./ticker.end trap EXIT exit 0}if [ $# -eq 1 ]; then tick=$1else tick=30fiif [ ! -f ticker.end ]; then touch ./ticker.endfitouch ./ticker.run.timerwhile [ 1 ]; do echo "*** "`date`" ***" ./ticker mypa.cfg echo "*sleeping $sleep" ./tick_sleep $tick ./ticker.run.timerI did the following system("nohup /wwwroot/htdocs/test/ticker/tick.sh 2>&1 &",$output);echo "<pre>"; print_r($output); echo "</pre>";then the output tells me this:touch: cannot touch `./ticker.end' access denied and also:*sleeping /wwwroot/htdocs/test/ticker/tick.sh: line 50 unknown file or directory.So aren't the privilidges ok ?thnxpMzQ, Link to comment https://forums.phpfreaks.com/topic/14978-exec-nohup-command/#findComment-60635 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.