Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Distributions»Gentoo»How to Setup Startup & Shutdown Script on Gentoo Linux

    How to Setup Startup & Shutdown Script on Gentoo Linux

    By 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.

    Advertisement

    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

    Related Posts

    Using Command Line Arguments in Python

    How to Input Password in Shell Script as Hidden Characters

    How to Configure CGI Scripts in Apache

    View 1 Comment

    1 Comment

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

      Thanks, You saved my time

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Error: EACCES: permission denied, scandir (Resolved)
    • How To Install Python 3.11 on Ubuntu 22.04 / 20.04
    • How to Install Python 3.11 on Amazon Linux 2
    • An Introduction to the “./configure” Command: Compiling Source Code in Linux
    • How to Install PHP 8.x on Pop!_OS
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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