how to automatic run a shell script at boot?
hi guys!
I wrote my first useful shell script! :) now I would like to make it run as soon as I log in. where should I put the shell scrip to auto run? thanks! |
Quote:
|
i just added the script to that location but it doesn't run. what else can I do?
|
putting the script in /usr/local/bin just means you can type the name without having to type the full path
if you now out the command you use to exicute the script in your ~/.bashrc it will runn whenever you log in (if you log in graphically it may not run untill you open a terminal) |
If you're using KDE you can place it in ~/.kde/Autostart and it will run whenever you start your kde session. I know gnome has a similar folder somewhere as well.
I don't think placing it in ~/.bashrc is a good idea, because then it will run every time you open a new bash shell, not just on startup. Unless you want that behavior, of course. Oh, and placing the script in /usr/local/bin will only allow you to run it by name only if that directory is set in your PATH variable. Most distros add this by default, but it's not guaranteed. /usr/local/bin is one of the recommended traditional locations in which to keep personal scripts and programs, however. |
I put the file in ~/.kde/Autostart but the script doesn't run. what can I do?
|
Quote:
Code:
When bash is invoked as an interactive login shell, or as a |
I created ~/.bash_profile and put my script there but it didn't start up when I logged in.
what else can I try? |
are you using this script on the office ? what role are you in the office (user or admin ?)
.bash_profile should be created auto when admin create an user. u should consult your admin then. if it's your laptop / personal desktop , just su in n' put it in the /etc/rc.local ... hehehe |
Quote:
|
ok... This is a personal computer, I'm running as user. I placed my script on /etc/rc.local (I had to md rc.local) but my script didn't run when I logged in.
I also put it on /etc/rc.d but it didn't work! last thing I did was to put the scrip on in /etc/init.d but nothing! any ideas? Thanks guys for your time! :) |
Quote:
Code:
$ ls -al ~ 1) runs 2) executes your script without any errors |
there u go:
drwxr-xr-x 37 cesar users 4096 2008-10-08 12:18 . drwxr-xr-x 5 root root 4096 2008-09-09 10:52 .. drwx------ 3 cesar users 4096 2008-09-09 11:42 .adobe -rw------- 1 cesar users 4928 2008-10-08 12:17 .bash_history drwxr-xr-x 2 cesar users 4096 2008-10-08 10:50 .bash_profile -rw-r--r-- 1 cesar users 1177 2008-09-09 10:44 .bashrc drwx------ 7 cesar users 4096 2008-09-09 11:00 .beagle drwxr-xr-x 2 cesar users 4096 2008-09-09 10:44 bin drwx------ 3 cesar users 4096 2008-09-29 16:09 .cache drwxr-xr-x 5 cesar users 4096 2008-09-29 16:08 .config drwx------ 3 cesar users 4096 2008-09-22 16:01 .dbus -rw-r--r-- 1 cesar users 51 2008-10-08 12:18 .DCOPserver_work__0 lrwxrwxrwx 1 cesar users 31 2008-10-08 12:18 .DCOPserver_work_:0 -> /home/cesar/.DCOPserver_work__0 drwx------ 2 cesar users 4096 2008-10-08 10:41 Desktop -rw------- 1 cesar users 26 2008-09-09 10:44 .dmrc drwxr-xr-x 4 cesar users 4096 2008-09-23 12:29 Documents -rw-r--r-- 1 cesar users 315 2008-09-09 10:44 .dvipsrc -rw-r--r-- 1 cesar users 1637 2008-09-09 10:44 .emacs drwxr-xr-x 3 cesar users 4096 2008-10-07 13:18 .emacs.d -rw------- 1 cesar users 16 2008-09-09 11:18 .esd_auth drwxr-xr-x 2 cesar users 4096 2008-09-09 10:44 .fontconfig drwxr-xr-x 2 cesar users 4096 2008-09-09 10:44 .fonts drwx------ 2 cesar users 4096 2008-10-08 10:43 .gconf drwx------ 2 cesar users 4096 2008-10-08 10:44 .gconfd drwx------ 3 cesar users 4096 2008-10-08 10:43 .gnome2 drwx------ 2 cesar users 4096 2008-09-09 11:02 .gnome2_private -rw-r--r-- 1 cesar users 16257 2008-09-09 10:44 .gnu-emacs drwx------ 3 cesar users 4096 2008-10-06 10:31 .gnupg drwxr-xr-x 10 cesar users 4096 2008-09-09 15:40 .housecall6.6 -rw-r--r-- 1 cesar users 25058 2008-09-09 15:39 hs_err_pid3895.log -rw------- 1 cesar users 185 2008-10-08 12:18 .ICEauthority -rw-r--r-- 1 cesar users 861 2008-09-09 10:44 .inputrc drwxr-xr-x 3 cesar users 4096 2008-09-09 15:38 .java drwx------ 4 cesar users 4096 2008-09-15 09:50 .kde drwx------ 3 cesar users 4096 2008-09-09 10:44 .local drwx------ 3 cesar users 4096 2008-09-09 15:38 .macromedia -rw-r--r-- 1 cesar users 3098 2008-09-29 12:30 .mailcap drwxr-xr-x 3 cesar users 4096 2008-09-09 10:48 .mcop drwxr-xr-x 4 cesar users 4096 2008-09-09 11:02 .mozilla -rw-r--r-- 1 cesar users 299 2008-10-08 09:52 music.sh drwx------ 3 cesar users 4096 2008-10-08 09:55 .ooo-2.0 -rw-r--r-- 1 cesar users 1028 2008-09-09 10:44 .profile drwxr-xr-x 2 cesar users 4096 2008-09-09 10:44 public_html drwxr-xr-x 2 cesar users 4096 2008-10-08 12:18 .qt -rw------- 1 cesar users 34548 2008-09-29 16:01 .realplayerrc -rw------- 1 cesar users 2078 2008-10-06 13:48 .recently-used -rw-r--r-- 1 cesar users 218 2008-09-09 13:12 .recently-used.xbel drwxr-xr-x 2 cesar users 4096 2008-09-09 10:44 .skel drwx------ 2 cesar users 4096 2008-10-02 12:08 .ssh drwx------ 4 cesar users 4096 2008-09-24 12:31 .thumbnails drwx------ 2 cesar users 4096 2008-09-09 12:11 .tsclient drwxr-xr-x 2 cesar users 4096 2008-09-09 11:16 .wapi drwxr-xr-x 4 cesar users 4096 2008-09-25 16:12 .wine drwxr-xr-x 2 cesar users 4096 2008-09-09 11:19 .wireshark -rw------- 1 cesar users 259 2008-10-08 12:18 .Xauthority -rw-r--r-- 1 cesar users 1940 2008-09-09 10:44 .xim.template drwxr-xr-x 2 cesar users 4096 2008-09-29 16:02 .xine -rwxr-xr-x 1 cesar users 1446 2008-09-09 10:44 .xinitrc.template -rw------- 1 cesar users 8816 2008-10-08 13:19 .xsession-errors -rw-r--r-- 1 cesar users 40690 2008-09-29 16:08 .y2log -rw-r--r-- 1 cesar users 281 2008-09-29 15:30 .y2usersettings |
Quote:
|
The proper place would be .bash_login and not .bash_profile.
If you want things to run when you exit, put them in .bash_logout Good outline of bash/shell initialization files: http://tldp.org/LDP/Bash-Beginners-G...ect_03_01.html |
All times are GMT -5. The time now is 04:41 AM. |