I am trying to keep running of a command after logout from ssh. I used the commands nohup source a.sh > a.txt and screen source a.sh > a.txt. But both gives
nohup: failed to run command 'source': No such file or directory```
error. In one question, it is said that use the absolute path of command but I couldn't find the exact location of source command. But I can use nohup directly with other commands such as cp. How can I solve this issue or are there better alternatives?
sourcethere? It means to execute the named script in the same shell, but since you're starting an external command (screenornohup) anyway...sourceis not an external command. It is a shell built-in, and nohup needs an external command to run. Ifa.shis on your PATH list, is executable, and has a shebang, that by itself is the command, likenohup a.sh. That is the proper way to do it. Otherwise,nohup bash a.shwill runa.sheven if it is not executable, and will ignore any shebang. Ifa.shis not in PATH, you will need to run it as./a.shor add whatever full pathname it is on. Note thatnohupdoes not mean anything useful unless you also run it in background.