autorun user scripts

Posted on 2001-07-10
Last Modified: 2013-12-27
In linux , I can add script in rc.local so that it can run automatically when system boot up.

How about in solaris ? I cannot find such file
Question by:adrianmak
  • 3
  • 3
  • 2
  • +1

Expert Comment

ID: 6272193
In Solaris is for
System up in /etc/rc2.d
for System down in /etc/rc0.d.

For System down only with
With reboot the system not start
the files in /etc/rc0.d
LVL 51

Expert Comment

ID: 6273469
do you mean to run the scripts each time the system boots, or just when a specific user logs on?

Expert Comment

ID: 6275819
In Solaris for user logs on
is 2 file.
1.- /etc/profile (For all users)
2.- $HOME/.profile (sh and ksh schell) for
     single user.
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

LVL 51

Expert Comment

ID: 6276279
> 1.- /etc/profile (For all users)


Not for users using other shell than ash, bash, bsh, esh, jsh, ksh, lsh, msh, pdksh, rksh, rsh(HP-UX only), sh, tsh, (and probably some more), as login shell.

Expert Comment

ID: 6276522
yes OK!
I write as example
for ksh and sh

Author Comment

ID: 6279385
I am not talking about user profile
but system auto run user scripts when system bootup

Accepted Solution

shanechambers earned 5 total points
ID: 6279426
I believe Otetelisanu's original answer was correct, but a little confusing, and not complete.

In Solaris (and any System 5 type Unix) what you need to do is add a file that contains what you want to happen, in the /etc/rc[1-3].d directories.  The name of the file determines if the script is for startup or shutdown, and what sequence it's ran in.

File naming breakdown:
(S|K) (Sequence Number) (topic)

For example:

Would be a KILL script for apache.  Note that the kill scripts 1-98 will run BEFORE this one will.

For example:

Would be a STARTUP script for apache.  Again, 1-98 will run before this one will.

As far as directories go, they differ for usage;
/etc/rc1.d     system administrator mode
/etc/rc2.d     multi-user mode (mostly system apps)
/etc/rc3.d     Extend multi-user mode (user apps)
/etc/rc4.d     alternative multi-user mode

The best way to set all of this up is to write your Start, and Kill script as one file, using a case $1 at the top.  When the system is starting up, or shutting down, and it runs the scripts, it will pass either "start" or "stop" to the script, which can be viewed as $1 (in sh, and ksh).

Once you have the script written, store it in /etc/init.d, and make symbolic links (ln -s) to it, from the directories that you want it to run.  For example;

From the /etc/rc3.d directory:
ln -s /etc/init.d/apache S99apache

This helps keep everything organized, and easier for the next person that has to change it.

Hope this helps!
LVL 51

Expert Comment

ID: 6279778
how about reading  /etc/init.d/README
It describes all you need to know ;-)

Expert Comment

ID: 6279978
>how about reading  /etc/init.d/README

I never knew that file exsisted! (probably because I started on old AT&T System 5 ;)

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux : can't create transaction lock error 1 68
Oracle Finace 3 79
Write an app 10 70
aix unix tar error 3 68
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question