0

I have a scheduled shell script running in a distributed environment. There are some scenarios where the process might get killed by some other processes. But I need the process to return 0 even after the failure/killed. Is there anyway to implement it in bash?

2 Answers2

1

Depends on the signal. Bash allows you to trap with the trap command, but if your script is being killed with SIGKILL (9), it is uninterruptible and untrappable.

brent
  • 3,521
  • 3
  • 26
  • 37
0

It sounds like this may be a case for some sort of watchdog process similar to how keepalived tracks processes.

At the simplest, the command pidof might be your friend here.

JohnA
  • 586
  • 3
  • 13