Как запустить сценарий оболочки в фоновом режиме?

Это означает, что ваша 32-разрядная ОС не поддерживает версию программного обеспечения amd64.

Попробуйте эту ссылку: http://www.oracle.com/technetwork/database/enterprise-edition /downloads/112010-linuxsoft-085393.html

39
задан 25 June 2012 в 03:18

16 ответов

В зависимости от того, что вы хотите, просто добавьте & amp; в конце команды

script.sh &
command &

Если вы используете его в терминале и хотите закрыть терминал, используйте nohup или disown

nohup

nohup script.sh &

disown

script &
disown

Если это не то, что вам нужно, будьте более конкретны в своем вопросе.

72
ответ дан 25 July 2018 в 20:28

В зависимости от того, что вы хотите, просто добавьте & amp; в конце команды

script.sh &
command &

Если вы используете его в терминале и хотите закрыть терминал, используйте nohup или disown

nohup

nohup script.sh &

disown

script &
disown

Если это не то, что вам нужно, будьте более конкретны в своем вопросе.

72
ответ дан 2 August 2018 в 02:18

В зависимости от того, что вы хотите, просто добавьте & amp; в конце команды

script.sh &
command &

Если вы используете его в терминале и хотите закрыть терминал, используйте nohup или disown

nohup

nohup script.sh &

disown

script &
disown

Если это не то, что вам нужно, будьте более конкретны в своем вопросе.

72
ответ дан 4 August 2018 в 18:00

В зависимости от того, что вы хотите, просто добавьте & amp; в конце команды

script.sh &
command &

Если вы используете его в терминале и хотите закрыть терминал, используйте nohup или disown

nohup

nohup script.sh &

disown

script &
disown

Если это не то, что вам нужно, будьте более конкретны в своем вопросе.

72
ответ дан 6 August 2018 в 02:32

В зависимости от того, что вы хотите, просто добавьте & amp; до конца команды

script.sh &
command &

Если вы запускаете его в терминале и хотите затем закрыть терминал, используйте nohup или disown

nohup

nohup script.sh &

disown

script &
disown

Если это не то, что вам нужно, уточните свой вопрос.

72
ответ дан 7 August 2018 в 20:09

В зависимости от того, что вы хотите, просто добавьте & amp; до конца команды

script.sh &
command &

Если вы запускаете его в терминале и хотите затем закрыть терминал, используйте nohup или disown

nohup

nohup script.sh &

disown

script &
disown

Если это не то, что вам нужно, уточните свой вопрос.

72
ответ дан 10 August 2018 в 08:31

В зависимости от того, что вы хотите, просто добавьте & amp; до конца команды

script.sh &
command &

Если вы запускаете его в терминале и хотите затем закрыть терминал, используйте nohup или disown

nohup

nohup script.sh &

disown

script &
disown

Если это не то, что вам нужно, уточните свой вопрос.

72
ответ дан 15 August 2018 в 20:38
  • 1
    Вас больше всего приветствуют – Panther 16 December 2011 в 03:59
  • 2
    Что, если мне, например, нужно запустить 2-х стека, а затем я хочу запустить htop, чтобы увидеть использование ЦП, но проблема в том, что 1-й скрипт начинает создавать вывод на консоль и, как представляется, предотвращает другие действия (запустите второй скрипт, запустите htop). – mrgloom 31 May 2016 в 22:33
  • 3
    если скрипт имеет инструкции печати, будут ли они отображаться на моем терминале? – Charlie Parker 14 September 2016 в 03:19

вы можете просто переключить экран и запустить скрипт на этом втором экране. Когда скрипт начинается с 2-го, переключитесь на 1-й и сделайте все, что захотите. Второй экран будет в фоновом режиме как дополнительное «окно терминала». и он не прекратит обработку, даже когда вы закроете свое ssh-соединение во время первого экрана.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» в вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указано Ansgar) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a , a предоставит вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions -screen

1
ответ дан 25 May 2018 в 15:54

вы можете просто переключить экран и запустить скрипт на этом втором экране. Когда скрипт начинается с 2-го, переключитесь на 1-й и сделайте все, что захотите. Второй экран будет в фоновом режиме как дополнительное «окно терминала». и он не перестанет обрабатываться, даже когда вы закроете свое ssh-соединение во время первого экрана.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» на вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указывал Ансгар) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a, "даст вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen

1
ответ дан 25 July 2018 в 20:28

вы можете просто переключить экран и запустить скрипт на этом втором экране. Когда скрипт начинается с 2-го, переключитесь на 1-й и сделайте все, что захотите. Второй экран будет в фоновом режиме как дополнительное «окно терминала». и он не перестанет обрабатываться, даже когда вы закроете свое ssh-соединение во время первого экрана.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» на вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указывал Ансгар) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a, "даст вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen

1
ответ дан 2 August 2018 в 02:18

вы можете просто переключить экран и запустить скрипт на этом втором экране. Когда скрипт начинается с 2-го, переключитесь на 1-й и сделайте все, что захотите. Второй экран будет в фоновом режиме как дополнительное «окно терминала». и он не перестанет обрабатываться, даже когда вы закроете свое ssh-соединение во время первого экрана.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» на вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указывал Ансгар) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a, "даст вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen

1
ответ дан 4 August 2018 в 18:00

Вы можете просто переключить экран и запустить свой скрипт на этом втором экране. Когда сценарий начнется 2-го, переключитесь обратно на 1-й и делайте что хотите. 2-й экран будет на заднем плане как дополнительное «окно терминала». и он не остановит обработку, даже когда вы закроете ваше ssh-соединение, находясь на первом экране.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» в вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указывал Ансгар) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a, "даст вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen

1
ответ дан 6 August 2018 в 02:32

Вы можете просто переключить экран и запустить свой скрипт на этом втором экране. Когда сценарий начнется 2-го, переключитесь обратно на 1-й и делайте что хотите. 2-й экран будет на заднем плане как дополнительное «окно терминала». и он не остановит обработку, даже когда вы закроете ваше ssh-соединение, находясь на первом экране.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» в вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указывал Ансгар) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a, "даст вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen

1
ответ дан 7 August 2018 в 20:09

Вы можете просто переключить экран и запустить свой скрипт на этом втором экране. Когда сценарий начнется 2-го, переключитесь обратно на 1-й и делайте что хотите. 2-й экран будет на заднем плане как дополнительное «окно терминала». и он не остановит обработку, даже когда вы закроете ваше ssh-соединение, находясь на первом экране.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» в вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указывал Ансгар) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a, "даст вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen

1
ответ дан 10 August 2018 в 08:31

Вы можете просто переключить экран и запустить свой скрипт на этом втором экране. Когда сценарий начнется 2-го, переключитесь обратно на 1-й и делайте что хотите. 2-й экран будет на заднем плане как дополнительное «окно терминала». и он не остановит обработку, даже когда вы закроете ваше ssh-соединение, находясь на первом экране.

screen --help
Use: screen [-opts] [cmd [args]]
 or: screen -r [host.tty]

Options:
-4            Resolve hostnames only to IPv4 addresses.
-6            Resolve hostnames only to IPv6 addresses.
-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

ctrl + a, c создаст новое «окно» в вашем активном сеансе экрана. Вы можете переключаться между несколькими окнами (как указывал Ансгар) с помощью ctrl + a, n для следующего окна и ctrl + a, p для предыдущего окна.

ctrl + a, "даст вам список всех ваших открытых окон.

Подробнее: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen

1
ответ дан 15 August 2018 в 20:38

Если вы хотите, чтобы скрипт оставался после закрытия терминала, другой вариант - использовать setsid:

setsid script.sh

Для получения дополнительной информации о различиях между nohup, disown, & и setsid: Разница между nohup, disown и & amp;

0
ответ дан 16 October 2018 в 18:59

Другие вопросы по тегам:

Похожие вопросы: