sudo nohup and redirection
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Trying to figure out the correct Cmnd_Alias for the sudoers file
The command i which to run without any password is the following:
sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
The lines i have added to sudoers file is:
## Cmnd alias specification
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Cmnd_Alias AXTOOLTTYSTOP = /etc/init.d/axtty stop
Cmnd_Alias AXTOOLTTYSTATUS = /etc/init.d/axtty status
Cmnd_Alias AXTOOLINTCTLSTART = /sbin/initctl start ttyp?
Cmnd_Alias AXTOOLINTCTLSTOP = /sbin/initctl stop ttyp?
## This will disable password request for the axtools commands
%sudoaxtools ALL=(root) NOPASSWD: AXTOOLTTYSTART, AXTOOLTTYSTOP, AXTOOLTTYSTATUS, AXTOOLINTCTLSTART, AXTOOLINTCTLSTOP
Defaults!AXTOOLTTYSTART !requiretty
Defaults!AXTOOLTTYSTOP !requiretty
The command in mention is ran inside a script (axopen), executed either by member of group sudoaxtools or root's crontab
/usr/local/bin/axopen
#!/bin/sh
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
echo -n "Checking for open connections"
while netstat -d | grep -q axel
do
((c++)) && ((c==900)) && break
echo -n "."
sleep 4
done
echo "done"
echo "Starting axtty service.."
$SUDO /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
sleep 4
$SUDO /etc/init.d/axtty status
When axopen is executed pÃÂ¥ member of sudoaxtools, then it still prompts for password. I expect its because of the >/dev/null 2>&1
pieces.
Secondary
The reason i'm using nohup is because the service for some reason will not start, when executed simply using
sudo /etc/init.d/axtty start
So if someone have ideas to fix that, it will be great as well.
centos sudo nohup
add a comment |Â
up vote
1
down vote
favorite
Trying to figure out the correct Cmnd_Alias for the sudoers file
The command i which to run without any password is the following:
sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
The lines i have added to sudoers file is:
## Cmnd alias specification
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Cmnd_Alias AXTOOLTTYSTOP = /etc/init.d/axtty stop
Cmnd_Alias AXTOOLTTYSTATUS = /etc/init.d/axtty status
Cmnd_Alias AXTOOLINTCTLSTART = /sbin/initctl start ttyp?
Cmnd_Alias AXTOOLINTCTLSTOP = /sbin/initctl stop ttyp?
## This will disable password request for the axtools commands
%sudoaxtools ALL=(root) NOPASSWD: AXTOOLTTYSTART, AXTOOLTTYSTOP, AXTOOLTTYSTATUS, AXTOOLINTCTLSTART, AXTOOLINTCTLSTOP
Defaults!AXTOOLTTYSTART !requiretty
Defaults!AXTOOLTTYSTOP !requiretty
The command in mention is ran inside a script (axopen), executed either by member of group sudoaxtools or root's crontab
/usr/local/bin/axopen
#!/bin/sh
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
echo -n "Checking for open connections"
while netstat -d | grep -q axel
do
((c++)) && ((c==900)) && break
echo -n "."
sleep 4
done
echo "done"
echo "Starting axtty service.."
$SUDO /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
sleep 4
$SUDO /etc/init.d/axtty status
When axopen is executed pÃÂ¥ member of sudoaxtools, then it still prompts for password. I expect its because of the >/dev/null 2>&1
pieces.
Secondary
The reason i'm using nohup is because the service for some reason will not start, when executed simply using
sudo /etc/init.d/axtty start
So if someone have ideas to fix that, it will be great as well.
centos sudo nohup
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Jul 22 at 13:53
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Trying to figure out the correct Cmnd_Alias for the sudoers file
The command i which to run without any password is the following:
sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
The lines i have added to sudoers file is:
## Cmnd alias specification
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Cmnd_Alias AXTOOLTTYSTOP = /etc/init.d/axtty stop
Cmnd_Alias AXTOOLTTYSTATUS = /etc/init.d/axtty status
Cmnd_Alias AXTOOLINTCTLSTART = /sbin/initctl start ttyp?
Cmnd_Alias AXTOOLINTCTLSTOP = /sbin/initctl stop ttyp?
## This will disable password request for the axtools commands
%sudoaxtools ALL=(root) NOPASSWD: AXTOOLTTYSTART, AXTOOLTTYSTOP, AXTOOLTTYSTATUS, AXTOOLINTCTLSTART, AXTOOLINTCTLSTOP
Defaults!AXTOOLTTYSTART !requiretty
Defaults!AXTOOLTTYSTOP !requiretty
The command in mention is ran inside a script (axopen), executed either by member of group sudoaxtools or root's crontab
/usr/local/bin/axopen
#!/bin/sh
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
echo -n "Checking for open connections"
while netstat -d | grep -q axel
do
((c++)) && ((c==900)) && break
echo -n "."
sleep 4
done
echo "done"
echo "Starting axtty service.."
$SUDO /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
sleep 4
$SUDO /etc/init.d/axtty status
When axopen is executed pÃÂ¥ member of sudoaxtools, then it still prompts for password. I expect its because of the >/dev/null 2>&1
pieces.
Secondary
The reason i'm using nohup is because the service for some reason will not start, when executed simply using
sudo /etc/init.d/axtty start
So if someone have ideas to fix that, it will be great as well.
centos sudo nohup
Trying to figure out the correct Cmnd_Alias for the sudoers file
The command i which to run without any password is the following:
sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
The lines i have added to sudoers file is:
## Cmnd alias specification
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Cmnd_Alias AXTOOLTTYSTOP = /etc/init.d/axtty stop
Cmnd_Alias AXTOOLTTYSTATUS = /etc/init.d/axtty status
Cmnd_Alias AXTOOLINTCTLSTART = /sbin/initctl start ttyp?
Cmnd_Alias AXTOOLINTCTLSTOP = /sbin/initctl stop ttyp?
## This will disable password request for the axtools commands
%sudoaxtools ALL=(root) NOPASSWD: AXTOOLTTYSTART, AXTOOLTTYSTOP, AXTOOLTTYSTATUS, AXTOOLINTCTLSTART, AXTOOLINTCTLSTOP
Defaults!AXTOOLTTYSTART !requiretty
Defaults!AXTOOLTTYSTOP !requiretty
The command in mention is ran inside a script (axopen), executed either by member of group sudoaxtools or root's crontab
/usr/local/bin/axopen
#!/bin/sh
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
echo -n "Checking for open connections"
while netstat -d | grep -q axel
do
((c++)) && ((c==900)) && break
echo -n "."
sleep 4
done
echo "done"
echo "Starting axtty service.."
$SUDO /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
sleep 4
$SUDO /etc/init.d/axtty status
When axopen is executed pÃÂ¥ member of sudoaxtools, then it still prompts for password. I expect its because of the >/dev/null 2>&1
pieces.
Secondary
The reason i'm using nohup is because the service for some reason will not start, when executed simply using
sudo /etc/init.d/axtty start
So if someone have ideas to fix that, it will be great as well.
centos sudo nohup
asked Jul 12 at 12:18
Phliplip
1066
1066
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Jul 22 at 13:53
add a comment |Â
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Jul 22 at 13:53
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Jul 22 at 13:53
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Jul 22 at 13:53
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
You don't want the redirections as part of the sudo rule. /etc/sudoers contains the program that is executed, and the redirections happen separately (at the containing shell level) from the sudo command:
(shell) sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
This calls sudo and redirects the output; sudo sees:
(sudo) /usr/bin/nohup /etc/init.d/axtty start
Change this sudoers line:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
to:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start
The redirect is meant to handle the nohup output, thats why i have it. If i Sudo the script itself, will i the. Have to sudo the lines inside the script?
â Phliplip
Jul 13 at 6:48
1
Leave the redirection in the script but take it out of sudoers.
â Jeff Schaller
Jul 13 at 10:01
add a comment |Â
up vote
0
down vote
accepted
I ended up putting the nohup script in a seperate bash script.
/usr/local/bin/axttystart
#!/bin/sh
## Intermediate bashscript in order to sudo nohup properly
/usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Then changed sudo'ers line containing the Cmnd_alias
for AXTOOLTTYSTART
to
Cmnd_Alias AXTOOLTTYSTART = /usr/local/bin/axttystart
The updated axopen script will instead for the sudoing the nohup line directly, sudo the axttystart
script
#!/bin/sh
[...]
echo "Starting axtty service.."
$SUDO /usr/local/bin/axttystart
sleep 4
$SUDO /etc/init.d/axtty status
Woops... You're correct, copy-paste mistake :-)
â Phliplip
Jul 15 at 21:28
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
You don't want the redirections as part of the sudo rule. /etc/sudoers contains the program that is executed, and the redirections happen separately (at the containing shell level) from the sudo command:
(shell) sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
This calls sudo and redirects the output; sudo sees:
(sudo) /usr/bin/nohup /etc/init.d/axtty start
Change this sudoers line:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
to:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start
The redirect is meant to handle the nohup output, thats why i have it. If i Sudo the script itself, will i the. Have to sudo the lines inside the script?
â Phliplip
Jul 13 at 6:48
1
Leave the redirection in the script but take it out of sudoers.
â Jeff Schaller
Jul 13 at 10:01
add a comment |Â
up vote
3
down vote
You don't want the redirections as part of the sudo rule. /etc/sudoers contains the program that is executed, and the redirections happen separately (at the containing shell level) from the sudo command:
(shell) sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
This calls sudo and redirects the output; sudo sees:
(sudo) /usr/bin/nohup /etc/init.d/axtty start
Change this sudoers line:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
to:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start
The redirect is meant to handle the nohup output, thats why i have it. If i Sudo the script itself, will i the. Have to sudo the lines inside the script?
â Phliplip
Jul 13 at 6:48
1
Leave the redirection in the script but take it out of sudoers.
â Jeff Schaller
Jul 13 at 10:01
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You don't want the redirections as part of the sudo rule. /etc/sudoers contains the program that is executed, and the redirections happen separately (at the containing shell level) from the sudo command:
(shell) sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
This calls sudo and redirects the output; sudo sees:
(sudo) /usr/bin/nohup /etc/init.d/axtty start
Change this sudoers line:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
to:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start
You don't want the redirections as part of the sudo rule. /etc/sudoers contains the program that is executed, and the redirections happen separately (at the containing shell level) from the sudo command:
(shell) sudo /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
This calls sudo and redirects the output; sudo sees:
(sudo) /usr/bin/nohup /etc/init.d/axtty start
Change this sudoers line:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
to:
Cmnd_Alias AXTOOLTTYSTART = /usr/bin/nohup /etc/init.d/axtty start
answered Jul 12 at 12:32
Jeff Schaller
30.8k846104
30.8k846104
The redirect is meant to handle the nohup output, thats why i have it. If i Sudo the script itself, will i the. Have to sudo the lines inside the script?
â Phliplip
Jul 13 at 6:48
1
Leave the redirection in the script but take it out of sudoers.
â Jeff Schaller
Jul 13 at 10:01
add a comment |Â
The redirect is meant to handle the nohup output, thats why i have it. If i Sudo the script itself, will i the. Have to sudo the lines inside the script?
â Phliplip
Jul 13 at 6:48
1
Leave the redirection in the script but take it out of sudoers.
â Jeff Schaller
Jul 13 at 10:01
The redirect is meant to handle the nohup output, thats why i have it. If i Sudo the script itself, will i the. Have to sudo the lines inside the script?
â Phliplip
Jul 13 at 6:48
The redirect is meant to handle the nohup output, thats why i have it. If i Sudo the script itself, will i the. Have to sudo the lines inside the script?
â Phliplip
Jul 13 at 6:48
1
1
Leave the redirection in the script but take it out of sudoers.
â Jeff Schaller
Jul 13 at 10:01
Leave the redirection in the script but take it out of sudoers.
â Jeff Schaller
Jul 13 at 10:01
add a comment |Â
up vote
0
down vote
accepted
I ended up putting the nohup script in a seperate bash script.
/usr/local/bin/axttystart
#!/bin/sh
## Intermediate bashscript in order to sudo nohup properly
/usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Then changed sudo'ers line containing the Cmnd_alias
for AXTOOLTTYSTART
to
Cmnd_Alias AXTOOLTTYSTART = /usr/local/bin/axttystart
The updated axopen script will instead for the sudoing the nohup line directly, sudo the axttystart
script
#!/bin/sh
[...]
echo "Starting axtty service.."
$SUDO /usr/local/bin/axttystart
sleep 4
$SUDO /etc/init.d/axtty status
Woops... You're correct, copy-paste mistake :-)
â Phliplip
Jul 15 at 21:28
add a comment |Â
up vote
0
down vote
accepted
I ended up putting the nohup script in a seperate bash script.
/usr/local/bin/axttystart
#!/bin/sh
## Intermediate bashscript in order to sudo nohup properly
/usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Then changed sudo'ers line containing the Cmnd_alias
for AXTOOLTTYSTART
to
Cmnd_Alias AXTOOLTTYSTART = /usr/local/bin/axttystart
The updated axopen script will instead for the sudoing the nohup line directly, sudo the axttystart
script
#!/bin/sh
[...]
echo "Starting axtty service.."
$SUDO /usr/local/bin/axttystart
sleep 4
$SUDO /etc/init.d/axtty status
Woops... You're correct, copy-paste mistake :-)
â Phliplip
Jul 15 at 21:28
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I ended up putting the nohup script in a seperate bash script.
/usr/local/bin/axttystart
#!/bin/sh
## Intermediate bashscript in order to sudo nohup properly
/usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Then changed sudo'ers line containing the Cmnd_alias
for AXTOOLTTYSTART
to
Cmnd_Alias AXTOOLTTYSTART = /usr/local/bin/axttystart
The updated axopen script will instead for the sudoing the nohup line directly, sudo the axttystart
script
#!/bin/sh
[...]
echo "Starting axtty service.."
$SUDO /usr/local/bin/axttystart
sleep 4
$SUDO /etc/init.d/axtty status
I ended up putting the nohup script in a seperate bash script.
/usr/local/bin/axttystart
#!/bin/sh
## Intermediate bashscript in order to sudo nohup properly
/usr/bin/nohup /etc/init.d/axtty start >/dev/null 2>&1
Then changed sudo'ers line containing the Cmnd_alias
for AXTOOLTTYSTART
to
Cmnd_Alias AXTOOLTTYSTART = /usr/local/bin/axttystart
The updated axopen script will instead for the sudoing the nohup line directly, sudo the axttystart
script
#!/bin/sh
[...]
echo "Starting axtty service.."
$SUDO /usr/local/bin/axttystart
sleep 4
$SUDO /etc/init.d/axtty status
edited Jul 15 at 21:27
answered Jul 15 at 20:47
Phliplip
1066
1066
Woops... You're correct, copy-paste mistake :-)
â Phliplip
Jul 15 at 21:28
add a comment |Â
Woops... You're correct, copy-paste mistake :-)
â Phliplip
Jul 15 at 21:28
Woops... You're correct, copy-paste mistake :-)
â Phliplip
Jul 15 at 21:28
Woops... You're correct, copy-paste mistake :-)
â Phliplip
Jul 15 at 21:28
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454882%2fsudo-nohup-and-redirection%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
If any of the answers solved your problem, please accept it by clicking the checkmark next to it. Thank you!
â Jeff Schaller
Jul 22 at 13:53