script in /etc/init.d not working
Here's something I really don't understand: I wrote a script to start a service at start up and put it in /etc/init.d
Then I ran "sudo update-rc.d SCRIPT defaults" and it all went good, no errors. However, when I reboot the server, the process is not running... When I do "sudo /etc/init.d/SCRIPT start", still nothing happens... I made a copy of that script in my home directory and ran it from there: perfect! After that, when I do "sudo /etc/init.d/SCRIPT start", it does run with no errors! very very strange, what am I doing wrong here? |
Quote:
|
Code:
# !/bin/sh |
It does sound very strange. If the problem persists, and the script does not run at the next boot, try
Code:
sudo /bin/sh -x /etc/init.d/SCRIPT start BTW it's easier to read scripts and output on LQ when they are in code tags (that's a link to instructions or it may be easier to use "Advanced Edit" mode which has a # button for code tags). |
Okay, that's the output:
Code:
laurent@server:~$ ps -e | grep cod4 When my pwd is Code:
/home/laurent Code:
Games/Cod4/bash StartCod4.sh When I'm in Code:
/home/laurent/Games/Cod4 Code:
bash StartCod4.sh Again, when my current dir is Code:
/home/laurent Code:
/etc/init.d/COD4 start But when my cur dir is Code:
/home/laurent/Games/Cod4 Code:
/etc/init.d/COD4 start So only if my current directory is /home/laurent/Games/Cod4 my script in /etc/init.d runs... Weird, isn't it? |
Presumably something in the /home/laurent/Games/Cod4/cod4_lnxded* commands depends on the current working directory. Do they use envars? Maybe PATHTOCOD4? If so, changing /etc/init.d/COD4 to export PATHTOCOD4=/home/laurent/Games/Cod4 would fix it. Alternatively, how about modifying /etc/init.d/COD4 to include cd /home/laurent/Games/Cod4 ?
|
Adding export to $PATHTOCOD4 did not work,
That's how my script looks now: Code:
# !/bin/sh Code:
cd: 51: can't cd to /home/laurent/Games/Cod4/cod4_lnxded_FFA Code:
CoD4 MP 1.7 build linux-i386 Jun 28 2008 I specify the root folder of the game in my variable and main is located in that root folder ofc. (Cod4/main) |
could you fire a "ls /home/laurent/Games/Cod4" and paste the results.
Please fire the command as root from / Is your /home a separate partition. Is it from NFS. does root user able to cd to that directory. ? |
Code:
laurent@server:/$ ls -l /home/laurent/Games/Cod4 |
The suggestion was to cd to the directory before (in time) running the commands so like:
Code:
start) Once you get it working it would be useful to add some error trapping. |
Quote:
|
Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
|
Quote:
|
All times are GMT -5. The time now is 01:20 PM. |