1833053 Members
2683 Online
110049 Solutions
New Discussion

nohup command

 
eric stewart
Frequent Advisor

nohup command

The nohup command creates the file nohup.out with -rw------- as the permissions.
We have groups of users that cover for each other but have their own login. I would like th nohup command to create the nohup.out with -rw-rw---- as the permissions.
Here was my solutions.
1. in the script that gets executed add a chmod g+rw nohup.out. The users did not wat this because it would mean work on their part.
2. create an alias nohup='>>nohup.out; chmod 660 nohup.out; /usr/bin/nohup '
The users liked this
The question I have is when I do the alias command, it shows nohup='nohup '
When I do type nohup it shows
nohup is an exported alias for nohup
Where does the nohup command alais gets set.
I can not seem to find it.
TIA
Good help is easy to find within forums
6 REPLIES 6
John Palmer
Honored Contributor

Re: nohup command

Hi Eric,

If you do 'man sh-posix' and search for nohup you will find that it is one of the set of exported aliases that are compiled into the shell. You can remove it with 'unalias nohup'.

Rather than creating an alias, I think that you will have more success by defining a shell function called nohup.

Regards,
John
Danny Engelbarts
Frequent Advisor

Re: nohup command

Eric,

The nohup alias is compiled into ksh (see; man ksh), you can unset or redefine it though.

Greetz, Danny
James R. Ferguson
Acclaimed Contributor

Re: nohup command

Eric:

'nohup' is one of several aliases that is compiled into the shell. It can still be redefined as you have done. If you want, you could place your alias into the user's $HOME/.profile. If the use of the alias as you have defined it is a "special case", however, I think you should consider aliasing it within the script that the users run, and NOT their global profile.

...JRF...
Victor BERRIDGE
Honored Contributor

Re: nohup command

I would use a shell, that contains:
nohup $1;
chmod 660 nohup.out

Or something like.

And use the shell as alias of nohup
eric stewart
Frequent Advisor

Re: nohup command

Thanks,
The second part of the question is why do they do it for nohup? Page 4 of the man ksh shows all of the others have a default parameter set.
TIA
Good help is easy to find within forums
James R. Ferguson
Acclaimed Contributor

Re: nohup command

Eric:

OK, second question's answer:

If you look at the nohup alias you will see that the last character of the alias value is a blank, as: nohup='nohup '. If you look at the man page for sh-posix, it notes: "If
the last character of the alias value is a blank, the word following the alias is also checked for alias substitution."

Thus, the alias as defined, allows you to use the 'nohup' command AND check the command following it for alias substitution.

...JRF...