Running custom command/script before system shutdown

    • OMV 4.x

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Running custom command/script before system shutdown

      Hi,

      I'm in progress building my home NAS. I'll be using it mainly on weekends (so it'll be down most of the time). Becouse I'm planning to use Snapraid and I don't want to maintain it manually (snapraid sync and snapraid scrub commands) I'd like these commands to be ran before the system shutdowns. Is it possible?
    • Yes, you can do that in the power management settings.
      Absolutely no support through PM!

      I must not fear.
      Fear is the mind-killer.
      Fear is the little-death that brings total obliteration.
      I will face my fear.
      I will permit it to pass over me and through me.
      And when it has gone past I will turn the inner eye to see its path.
      Where the fear has gone there will be nothing.
      Only I will remain.

      Litany against fear by Bene Gesserit
    • Sorry, maybe it is in the crown scheduled job page. There you can select shutdown and reboot as time option.
      Absolutely no support through PM!

      I must not fear.
      Fear is the mind-killer.
      Fear is the little-death that brings total obliteration.
      I will face my fear.
      I will permit it to pass over me and through me.
      And when it has gone past I will turn the inner eye to see its path.
      Where the fear has gone there will be nothing.
      Only I will remain.

      Litany against fear by Bene Gesserit
    • Ah i saw that cron only supports @reboot. If you want to execute a script on shitdown, why not using a custom systemd unit file?
      Absolutely no support through PM!

      I must not fear.
      Fear is the mind-killer.
      Fear is the little-death that brings total obliteration.
      I will face my fear.
      I will permit it to pass over me and through me.
      And when it has gone past I will turn the inner eye to see its path.
      Where the fear has gone there will be nothing.
      Only I will remain.

      Litany against fear by Bene Gesserit
    • votdev wrote:

      If you want to execute a script on shutdown, why not using a custom systemd unit file?
      I would also regard an easier possibility to execute a script on shutdown.
      In my case I had a similar request (a script to empty samba recycle bin) and without deeper linux knowledge I wasn´t able to use a systemd unit file for this purpose. I then decided to let it run on reboot at the risk of additional system load and a longer time required up to system availability.
      OMV 3.0.90 (Gray style)
      ASRock Rack C2550D4I - 16GB ECC - 6x WD RED 3TB (ZFS 2x3 Striped RaidZ1)- Fractal Design Node 304
    • ORXORNOR wrote:

      I'd like these commands to be ran before the system shutdowns
      Why not at start up with a delay? Or as cron or, if the server is switched down a significant portion of time, anacron job every x days?
      Odroid HC2 - armbian - Seagate ST4000DM004 - OMV4.x
      Asrock Q1900DC-ITX - 16GB - 2x Seagate ST3000VN000 - Intenso SSD 120GB - OMV4.x
      :!: Backup - Solutions to common problems - OMV setup videos - OMV4 Documentation - user guide :!:
    • votdev wrote:

      Ah i saw that cron only supports @reboot. If you want to execute a script on shitdown, why not using a custom systemd unit file?
      I've been trying without any luck. This solution is described on the internet as "hackish". Most of the people are not able get it ever working.



      macom wrote:

      ORXORNOR wrote:

      I'd like these commands to be ran before the system shutdowns
      Why not at start up with a delay? Or as cron or, if the server is switched down a significant portion of time, anacron job every x days?
      If I don't find a way to call the sync on shutdown I'll go that way... I'll just set it on @reboot with nice -20. Hopefully the machine will be usable during syncing :)