开发者

Prevent Gnome Terminal From Exiting After Execution [duplicate]

This question already has answers here: Avoid gnome-terminal close after script execution? (10 answers) Closed 7 years ago.

How do you prevent gnome-terminal from exiting after its given command has exited?开发者_高级运维

I'm calling gnome-terminal from a cronjob, in order to create a terminal accessible to the user. The terminal is initially given a specific program to run. e.g.

gnome-terminal --tab -e "/usr/bin/myprog"

This works fine, except that when "myprog" exits, so does the gnome-terminal. How do I keep it running, but just drop back to a terminal prompt?


Try this:

gnome-terminal --tab -- "/bin/bash -c '/usr/bin/myprog; exec /bin/bash -i'"


Prevent Gnome Terminal From Exiting After Execution [duplicate]

Create a profile (i.e. hold), set "When command exits: Hold the terminal open" and then

$ gnome-terminal --tab --profile hold -e /usr/bin/myprog


Create a shell script like this:

#!/bin/bash
# myprog-wrapper.sh - runs /usr/bin/myprog and then starts a new bash session
/usr/bin/myprog
/bin/bash

Give the shell script execute permission.

Then set up your cron job to call this script instead of directly calling myprog:

gnome-terminal --tab -e "/path/to/myprog-wrapper.sh"

Replace /bin/bash with your shell of choice.


You could use xterm or rxvt-unicode instead of gnome-terminal, both of which have the -hold option for this purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜