Forum Home
Press F1
 
Thread ID: 100261 2009-06-01 12:11:00 Ubuntu - Adding script to startup WarNox (8772) Press F1
Post ID Timestamp Content User
778885 2009-06-01 12:11:00 Hey!

So I want to add a script to startup to start up 'vncserver'.

I did the following.

1. Created the script in /etc/init.d/:


#!/bin/bash
echo "before" >> /home/gregor/Documents/logfile
vncserver
echo "before" >> /home/gregor/Documents/logfile

2.


sudo chmod +x vncstartup

3.


sudo update-rc.d vncstartup defaults

---

When I restart the machine the log file ends up with:


before
after
before
after

but it's as if the 'vncserver' command is not even run!?

If I run the script manually it works fine.

Anyone have any idea what the problem is and why the script is run twice on logon but only a part of it?!

Thanks,




Gregor
WarNox (8772)
778886 2009-06-01 14:49:00 Chances are you're passing it the wrong options (most likely) or it's missing from your PATH (unlikely). Try piping the output of vncserver into your logfile to see what's going wrong:
vncserver 2>&1 >> /home/gregor/Documents/logfile
Erayd (23)
778887 2009-06-02 00:22:00 Ok, I'll try this tonight and let you know how I go. WarNox (8772)
778888 2009-06-02 08:18:00 Alright so I edited the startup script to read:



#!/bin/bash
echo "starting vncserver" >> /home/gregor/Documents/vncserverlog
runlevel >> /home/gregor/Documents/vncserverlog
vncserver
vncserver 2>&1 >> /home/gregor/Documents/vncserverlog
echo "after vncserver start" >> /home/gregor/Documents/vncserverlog


And the output is now:



starting vncserver
2 6
after vncserver start
starting vncserver
N 2
after vncserver start


I added the 'runlevel' line to see which runlevel the commands are called at, not that it helps me at all :illogical

So it is still run twice!? and there is no output at all for the two 'vncserver' lines.

Thanks again,




Gregor

---

I just ran the script manually with:

./gregorvnc

and the script is run twice when I do that too.
WarNox (8772)
778889 2009-06-02 14:58:00 Why not just add the following to /etc/init.d/rc.local
vncserver &
Chilling_Silence (9)
778890 2009-06-05 12:44:00 ubuntu doesn't use the rc.local file, but the scripts in /etc/init.d/... as far as i know. WarNox (8772)
778891 2009-06-05 21:32:00 To quote my ubuntu server (8.04 mind you but still):

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0


:)
Chilling_Silence (9)
1