简体   繁体   English

以任何方式在其他Shell中继续运行脚本

[英]Any way to continue the running script in other shell

I created a script in which I login as a different user(superuser) during the execution of the script but the commands after this are put on hold until i logoff the other user. 我创建了一个脚本,在该脚本中,我在执行脚本时以其他用户(超级用户)身份登录,但是此后的命令将保留,直到我注销另一个用户为止。 Is there any way that the script following the command to login(as superuser) shall continue executing in the new logged in user? 以新用户身份登录后(以超级用户身份)执行命令后的脚本是否可以继续执行?

You can run the script using nohup, which will run until the script is completed regardless of user log off. 您可以使用nohup运行脚本,该脚本将一直运行到脚本完成为止,而与用户注销无关。

nohup /path/to/script.sh nohup /path/to/script.sh

You can also run this in the background by using: nohup /path/to/script.sh & 您也可以使用以下命令在后台运行此命令:nohup /path/to/script.sh&

http://linux.die.net/man/1/nohup http://linux.die.net/man/1/nohup

Whatever commands you are executing after loging to superuser, just collect all them in on script file. 登录到超级用户后无论执行什么命令,只需将所有命令收集到脚本文件中即可。 And execute them with- 然后用-

nohup script.sh &

nohup in combination with "&" will help you to exit superuser session immediately. nohup与“&”结合使用将帮助您立即退出超级用户会话。

Actually I am using dzdo command,not su or sudo.When dzdo is used with -u & -i, it allows us to login as a different user (not madatorily as a superuser), (in my case, it was a superuser). 实际上我使用的是dzdo命令,而不是su或sudo。当dzdo与-u&-i一起使用时,它允许我们以其他用户身份登录(而不是超级用户)(在我的情况下,它是超级用户) 。 After i gave the command: dzdo -iu I got logged in as the other user but the script paused running after this because, it was a new shell/user completely & the script resumed itself as soon as i was logging off. 输入以下命令后:dzdo -iu我以其他用户身份登录,但此后脚本暂停运行,因为这完全是一个新的shell /用户,并且注销后脚本便自动恢复。 I found a way, I can create a script in the superuser's directory & invoke that script through my local script using the command: dzdo -u Eg: dzdo -u newuser sh abc.sh 我找到了一种方法,可以在超级用户目录中创建脚本并使用以下命令通过本地脚本调用该脚本:dzdo -u例如:dzdo -u newuser sh abc.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM