I'm working on a Bash script where I need to manage a timer using inotifywait. The script logs show a process ID (PID) that doesn't match the PID I get when I run `ps aux | grep "[s]leep 10"`. It consistently appears to be off by one. I'm not sure what I'm doing wrong. The aim is to reset the timer with each update from inotifywait and then execute a command afterward. Any insights on this issue would be really appreciated!
1 Answer
It looks like the issue arises because you're backgrounding the `trigger_update` function instead of the `sleep` command itself. When you run a command in the background, the PID you capture is for that subshell running the entire function, not just the `sleep`. To fix this, try backgrounding the `sleep` within the function directly. This should give you the correct PID for your timer.
Thanks for the tip! Is there a more effective way to manage timers without creating conflicts or stacking them?