How to run a script automatically when AIX version 7 server reboots?

Am new to AIX please help me. I have AIX7 server. When ever the system reboots my script need to run automatically. This will help me to start my application automatically after the server reboot.

Thanks,
Prince Wells

put your script in this file

 
/etc/rc.d/

I have lot of rc1.d, rc2.d,rc3.d and init directories in /etc/rc.d

Where i have to add my script? Please help me.

check /etc/inittab file

  • Just create a script file in /etc called rc.myscript and put your startup command in the file
  • edit your inttab and this line:
myscript:2:once:/etc/rc.myscript > /dev/null 2>&1

ahem, ... yes and no. While this is certainly true and will certainly work one should - out of habit - use the mechanisms the OS offers to do so. In this case this means to use the command mkitab .

Be sure to read the man page of mkitab before you do that.

I hope this helps.

bakunin

I still believe that applications should be started from /etc/rc.d/rc2.d via link - the startscript itself should be in /etc/rc.d/init.d) while service-like applications like cluster software, security software and alikes should be started from inittab.

It is a pain when the system doesn't boot because some application script started from inittab doesnt work or is started at the wrong time of the system boot sequence - or even worse because the entry in inittab is wrong / not working at all - and I myself prefer to rename scripts in init.d when I do not want them to start for any reason rather than to over and over modify inittab - but this might be just personal taste.

Regards
zxmaus

My friend .. there is file under /etc called rc in the end of that file just put your script and it'll be automatically started after the reboots

Thanks..

this is good idea.

or you can use

My /etc/rc.local file looks like this..

[root@localhost test]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
#ifconfig p33p1 1.1.31.240 netmask 255.255.255.0
#route add default gw 1.1.31.1
sh /usr/share/tomcat/apache-tomcat-6.0.26/bin/startup.sh

May help you..

There is no rc.local by default, in AIX (at least not in 5.3!). If you want to add one, you'll need to let /etc/inittab know about it.

And what if you want to stop the program when the server shuts down?

I prefer the option zxmaus suggested.

1 Like

oh , thank you scottn for this information..