Quantcast
Channel: Long running bash update script loop. How to handle terminating better? - Server Fault
Viewing all articles
Browse latest Browse all 2

Long running bash update script loop. How to handle terminating better?

$
0
0

I have a bash script that downloads some data, runs a process to import it, then sleeps for a little while (about an hour). It's running fine as a systemd service (on Ubuntu 16.04 & 18.04)

But I am afraid that interrupting the import process could leave the database in an inconsistent state, so I want to prevent it being interrupted. i.e. systemctl stop mything should block until the import process is finished. Other steps in the process can be interrupted at will.

Is there any easy way in a bash script to run a command and say "don't propagate the SIGKILL signal to this command"? (nohup blocks SIGHUP). For other, similar scripts, I've used bash's trap to 'catch' the signal which stops bash killing the process, but then the sleep isn't killed, so I had to run sleep in the background and wait on it (and then kill the sleep in the signal handler). Which seems overtly complicated.

Is there a better way? Is there a nosigkill command (like nohup) which will block sigkill for just that command?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images