Sudo + Nohup = no password?

Little confused here

When i go to run sudo nohup ./script.ksh &

I dont get asked for a password.
It starts a process ID, I can see it when i do a ps -ef | grep script.
But I dont get an output file from my script, so its not doing anything.

What gives?

does it have to do the "&" ?

No I did not recently run a SUDO command, so the credentials are not cached.

Thoughts?

Not being asked for a password could be a result of NOPASSWD option in the /etc/sudoers file.

Can you post the script here? Also, try to use /usr/bin/nohup instead of the shell's built-in nohup. This implementation of nohup sends standard output to nohup.out (in the current working directory, if denied, in $HOME dir) by default and can be redirected like this:

nohup COMMAND >FILE

Which shell has a nohup builtin?

Regards,
Alister

C-shell has a built-in nohup command.

[unixuser@blue ~]$ csh
[unixuser@blue ~]$ nohup
nohup: Can't from terminal.
[unixuser@blue ~]$ which nohup
nohup: shell built-in command.

---------- Post updated at 04:12 PM ---------- Previous update was at 03:56 PM ----------

By the way, actually, I just read the post again and now I can tell for sure it's happening because of the '&'. The whole "sudo" process is being moved to the back ground.

To avoid this, nohup has to be called from within the script. You just have to fork out a separate process and put it in background. All has to be done from within the script. I might be able to tell the exact changes need to be done only after seeing the script.

2 Likes

Yep, ok well if i do this without the "&" it works as it should thanks!