• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2226
  • Last Modified:

How to put a shell script in the inittab to startup everytime the server starts up

I need help/steps on how to create/enter/make an inittab for a shell script I have to startup automatically.

*I am running AIX 5.3
0
AIX25
Asked:
AIX25
  • 4
  • 3
3 Solutions
 
woolmilkporcCommented:
Hi,
the format of an /etc/inittab entry is

identifier:runlevel:action:command

where action can be e.g. once (fire and forget), wait (fire and wait for completion), respawn (fire if not active) and off.
AIX default runlevel (multi-user & network) is 2

a typical entry could be

myjob:2:once:/path/to/my/script my para meters >/path/to/my/logfile 2>/path/to/errorlog/file

You can use vi to put the entry in /etc/inittab or you can use the 'mkitab' utility.
See man mkitab for more.
To list inittab's contents use lsitab. See man lsitab.

wmp


0
 
AIX25Author Commented:
Ok so if my script is called monitor-ifconfig.ksh and the path is /scripts/SA_Scripts/monitor-ifconfig.ksh.
Then it would be:
identifier???:2:respawn:/scripts/SA_Scripts/monitor-ifconfig.ksh
Is this above inittab correct?
What would be my identifier??

Thank you
0
 
woolmilkporcCommented:
The identifier is a 'label' you give to that entry. It is used by mkitab (-i flag) to find an entry point for adding new lines. (see man mkitab)
Basically, you're free to choose whatever gives you some mnemonic for your entry.

Attention: AIX init scans its inittab regularly. Should it find a 'respawn' entry whose process doesn't run, it will start it, and will only pause doing so if the process respawns too rapidly.

Take care to collect or discard the script's output (if any), else it will go to the console.

wmp

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
AIX25Author Commented:
so you recommend an action of 'wait'?
0
 
woolmilkporcCommented:
The normal way is using once.
A script you place in inittab should be reliable enough to start and run gracefully.
wait is meant for a configuration where the system should not continue initializing until that special script has run (and terminated).
respawn is meant for processes that are most important for the correct functioning of the whole system and should be restarted if terminated accidentally (cron and console (getty) are examples).

wmp

0
 
AIX25Author Commented:
woolmilkporc made my problem very easy to understand!
0
 
AIX25Author Commented:
I have an open question if you would like to help and are good at shell scripting.
ID: 24159752

Thank you for all your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now