• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
  • OS
    • HPUX
    • Linux
  • Commands & tools
    • Commands
    • Software & Tools
    • System services
  • Cloud computing
    • AWS CSA preparation guide!
    • Cloud Services
  • Tips & Tricks
  • Linux commands
You are here: Home / Howto

How to run your script with system boot in HPUX

Published: January 12, 2017 | Modified: June 20, 2020 | 1,203 views



A how-to guide for a running script or starting your custom coded daemon/service at system boot. Use the RC script directory to load custom daemons at boot.

There are many daemons and system services which starts with system boot. You might be wondering how to add your own script or customized daemon or service in boot sequence so that when the system is booted its there already running.

In this article, we will be seeing how to run your script with system boot in HPUX. First, we will create a small script that will be taking the start, stop arguments to call your original script/daemon/service. Then we will keep this script inside an appropriate run level RC directory so that it will be executed when the system enters that run level.

Let’s assume you have /usr/sbin/my_agentd to start at boot. You can create an additional script /sbin/init.d/my_agent which can take the start, stop options like below :

# cat /sbin/init.d/my_agent

choice=$1
case $choice in
"start")
        cd /usr/sbin
        ./my_agentd <other option if any>
        ;;
"stop")
        ps -ef|grep -i my_agentd|grep -v grep|awk '{print $2}'|xargs kill -9
        ;;
esac

The above script will take the start and stop as arguments. It will execute your agent binary when supplied with start argument and kills your running agent if supplied with a stop option. It is advisable to keep this script in /sbin/init.d directory since there lives all start, stop scripts of daemons or services.

Make sure you give proper executable permissions to this newly crafted script file.

# chmod 555 /sbin/init.d/my_agent

Now the last step is to have this script executed with run-level 3 (multi-user mode). To accomplish this, create a link for this file in /sbin/rc3.d directory.

/sbin/rc3.d directory contains all run level 3 related startup scripts. Keeping yours in it makes sure that it will start with run level 3.

# cd /sbin/rc3.d
# ln -s /sbin/init.d/my_agent S99my_agent

You are all set!

Now, whenever your system enters run level 3. It will try to execute S99my_agent file with the start argument. Which in turn calls /sbin/init.d/my_agent since its a link. When /sbin/init.d/my_agent (our coded script) gets start an argument, it calls /usr/sbin/my_agentd which is your customized daemon/service/script.

⇠ Previous article
How to restart Apache server in Linux
Next article ⇢
Ulimit value : All you need to know

Related stuff:

  • Execute command at shutdown and boot in Suse Linux
  • How to install EC2 Linux server in AWS with screenshots
  • How to enable repository using subscription-manager in RHEL
  • How to import VG using different VG name
  • How to remount filesystem in the read-write mode under Linux
  • How to remove password expiry in linux
  • How to forward SSH key in Putty
  • How to setup domain name in Linux server
  • How to add UUID entry in /etc/fstab in Linux
  • bdf command formatted output in hpux
  • How to safely remove disk from LVM
  • Howto get CPU details in HPUX

Filed Under: Howto Tagged With: Auto start scripts, Automation in HPUX, Code for start stop script, Customize own deamon, RC scripts, Run script at boot, Start daemon at boot, Start software with boot in Linux

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Popular posts

  • How to start, stop & restart MariaDB server in Linux
  • How to reset iptables to the default settings
  • 4 ways to check the size of physical memory (RAM) in Linux
  • How to list YUM repositories in RHEL / CentOS
  • How to rescan disk in Linux after extending VMware disk
  • How to configure login banners in Linux (RedHat, Ubuntu, CentOS, Fedora)
  • How to remount filesystem in the read-write mode under Linux
  • mount.nfs: requested NFS version or transport protocol is not supported
  • MobaXterm X11 proxy: Authorisation not recognised
  • What are the huge pages in Linux?

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2020 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.