Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Distributions»Gentoo»How to Setup Startup & Shutdown Script on Gentoo Linux

    How to Setup Startup & Shutdown Script on Gentoo Linux

    RahulBy RahulAugust 21, 20161 Min ReadUpdated:August 22, 2016

    Sometimes you required to run a command or shell script during system startup and shutdown. This is helpful for starting a service on system start and stop it during system shutdown. This tutorial will help you to run scripts on system startup and shutdown on Gentoo Linux.

    Now the scripts inside /etc/local.d/ directory with suffix .start will be executed at system startup and all the scripts with suffix .stop will be executed during system shutdown. First make sure you have enabled local.d scripts using below steps.

    Enable local.d Scripts

    To start the local.d scripts at boot time, add its init.d script to the default runlevel

    # rc-update add local default
    

    Now start the service by making OpenRC check for stopped services in the default runlevel:

    # rc-service local start
    

    Run Script on Startup

    Create a script /etc/local.d/myService.start and put your content in it. This will be executed during system boot.

    # vi /etc/local.d/myService.start
    
    #!/bin/sh
    # Show below message on system startup
    echo "Welcome back!"
    

    Run Script on Shutdown

    Create a script /etc/local.d/myService.stop and put your content in it. This will be executed during system shutdown.

    # vi /etc/local.d/myService.stop
    
    #!/bin/sh
    # Show below message on system shutdown
    echo "Good bye!"
    
    Gentoo scripts
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHadoop – Namenode is in safe mode
    Next Article Best VPN For Linux (Ubuntu & Fedora)

    Related Posts

    How to Pass Command Line Arguments to Python Script

    Updated:September 19, 20191 Min Read

    How to Input Password in Shell Script as Hidden Characters

    Updated:November 1, 20171 Min Read

    How to Configure CGI Scripts in Apache

    Updated:December 15, 20192 Mins Read

    How to Use Functions in Bash Shell Scripts

    2 Mins Read

    1 Comment

    1. Jackson on August 23, 2016 5:15 am

      Thanks, You saved my time

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.