I am trying to run a script in the background even after closing the terminal. I have searched and searched and tried nohup
and disown
but neither seem to be working. When I close a terminal window, I get the typical Closing this window will terminate the running processes: watch.
message. That ends up terminating my background process, even when using nohup
or disown
. What could be the problem?
My code is a simple two lines
cmd="nohup watch -n 1 sudo /etc/block.sh > /dev/null"
$cmd & # blocks automatically
It is located in .bash_profile
, because I want it to start up whenever I open a new terminal.
You can ignore the sudo; I've already found a way to execute a sudo command without entering the password.
I am using Mac OSX.