Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd, 2017 please sign up again. Thanks!

  1. More ways to get the info! - we shoot all of our new original content out as well as random messages on Twitter and our newsletter!. Twitter | Newsletter
    Dismiss Notice

Simple - run a script on reboot/shutdown

Discussion in 'General Linux' started by AntiRix, Mar 13, 2019.

  1. AntiRix

    AntiRix New Member

    Mar 13, 2019
    Likes Received:

    I've been pulling my hair out for hours trying to get something so simple to work. Here's what I've done:

    1. Created /etc/init.d/reboot-report with permissions -rwxr-xr-x

            echo "test3\n" > /var/www/html/logging/debug
    case "$1" in
    I shouldn't have to have the case statement, because the script should just run on shutdown, not having a start/stop state. Just did it anyway because it wasn't working without it, so I tried that.

    2. update-rc.d didn't create the symlink, so in /etc/rc6.d/, I manually created:
    S00reboot-report -> ../init.d/reboot-report
    This has full permissions of lrwxrwxrwx.


    I read about needing a lock file at /var/lock/subsys/reboot-report. Shouldn't need it, because the script doesn't have a state. It should just run once on shutdown. Regardless, I created an empty file there with touch, but the script still didn't run on reboot. The file disappeared once the machine rebooted.

    I did the same for shutdown-report in rc0.d. Doesn't work either.

    Any help would be greatly appreciated - my patience is wearing very thin with this.

    (Log in to hide this advertisement)

  2. shankar12

    shankar12 New Member

    Mar 14, 2019
    Likes Received:

    I tried the same and the script didn't run. You can run the script at reboot or shutdown using cronjob and for that you need to write the following line in the cronjob.

    @reboot /bin/bash /root/test.sh

    where /root/test.sh is the script.
    wizardfromoz and Condobloke like this.

Share This Page