4

I tried execute my script using:

nohup . test.sh

and

nohup . ./test.sh

However, I got: nohup: failed to run command `.': Permission denied each time.

What I'm really trying to do is in my script be able to call commands that I've aliased, but it only works with ". test.sh" or ". ./test.sh", not "./test.sh" or "sh ./test.sh" as I get a "command not found". But I'd like to be able to run this with "nohup".

13

nohup runs an executable. You need to pass it an external command, i.e. an executable file. You can't call nohup on a shell construct such as an alias, function or builtin. nohup runs a new process, it doesn't run something inside the existing shell process (since nohup itself is a separate process), so nohup . … doesn't make sense.

nohup ./test.sh is the correct way to run a shell script with nohup. Make sure that the script properly starts with a shebang line (#!/bin/sh) and that the file is executable (chmod +x ./test.sh).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.