Exec-Binding: keep command running when it terminates openhab

Hi everybody!

My first post on this forum :blush:.
I have the following problem: when running my backup script (which calls raspiBackup) it terminates openhab (via systemctl), which in turn, terminates my backup script.

I’m using the following configuration:

Thing exec:command:rpiBackup	[command="/usr/bin/sudo /usr/bin/nohup /home/openhabian/RaspiBackupWrapper/raspiBackupWrapper &", autorun=false, interval=0]

Switch		it_rpi_Backup	"start backup"			{channel="exec:command:rpiBackup:run"}

nohup is supposed to detach my script from the command line it’s called from, unfortunately it still receives a SIGTERM and stops before finishing. But even without the nohup part (and the & of course), I can’t get it to work.

Is there any way I can tell openhab to execute a script and then leave it alone, no matter what?

Some help would be very much appreciated!

  • Platform information:
    • Hardware: Raspberry Pi 3 Model B Rev 1.2
    • OS: Raspbian GNU/Linux 9 (stretch)/Openhabian
    • openHAB version: 2.4.0-1

You mean you want a very long Thing timeout? I think you can set up to a couple of days at least.

Thanks for your reply, I just tested your suggestion, unfortunately a timeout it does not solve my problem.

The script basically mounts a network share and stops services which might interrupt the backup process, including openhab, and then proceeds to the actual backing up. Once it tells openhab to shut down though, openhab in turn shuts my script down, preventing it from doing it’s job.

I would prefer to solve this in openhab itself, but any hints to a os-level solution are welcome as well, of course.

Ah, well yes it would, this is doing what it was told to do.

I think most folk run a cron job in the middle of the night.

Thanks for the link, didn’t see that.
cron is probably the way to go. A switch for a quick backup before any major tinkering would be quite comfortable though :smile:

I will settle for the regular backup for now then. Still, any more ideas are welcome.

I’m sure there is more than one way to set up a little service that listens for some trigger from another service (openHAB) to do your backup.