Starting a Script at System Boot on AIX 7

Victor Rodriguez
Victor Rodriguez used Ask the Experts™
on
I want to know how can I start a script at the system startup. I tried to make a sh file under /etc/rc.d/rc3.d/ but I rebooted the Os and it does not start my script as I want. :(.

Regards,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
If you're looking for it to start at boot up, I believe it needs to be in rc2.d

Also, make sure your script is executable  
# chmod +x <your-script>

Open in new window


Ken
Dr. KlahnPrincipal Software Engineer

Commented:
Assuming that your system's cron supports reboot scripts, the easiest way is to have cron execute the script at system reboot.  Then there is no fiddling with system directories involved.

https://www.cyberciti.biz/faq/linux-execute-cron-job-after-system-reboot/
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Two general ways.

1) /etc/rc.local (if AIX supports this method).

2) CRON - @reboot path-to-your-script
Carlos IjalbaIT Systems Director
Top Expert 2014

Commented:
For this kind of things, AIX uses the inittab, no need to fiddle with other methods (although they are supported for compatibility with other UNIX).

To add and remove scripts or commands to the inittab there are specific AIX commands that check the file's integrity (similar to visudo for /etc/sudoers). The inittab resides in /etc/inittab, and it's not recommended to edit it directly.

To see the actual inittab, use the "lsitab" command, to add an entry to the inittab use the "mkitab" cmd, use "man mkitab" to see the options.

Also AIX has rc.startup and rc.shutdown scripts, where you usually place your app startup and shutdown scripts.

For example, Oracle DB startup and shutdown will be put in rc.startup and rc.shutdown scripts, and agents and daemons like nagios NRPE or LPAR2RRD will be put in inittab.

A good post about the different options can be seen on IBM developerworks:

https://www.ibm.com/developerworks/aix/library/au-aix-autostartup-shutdown-scripts/index.html
Hi,

yes use /etc/inittab for this as Carlos mentioned.

vi /etc/inittab

Open in new window


Cheers

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial