How to run a command in background always?

user3846091

the below command when I run from the terminal will keep posting the output to message.log

cf logs broker-analytics > /var/www/cfbrokerlogs/message.log

However, if i close my terminal it will stop working. How do i make it run in the background all the time ? Also If for any reason if it stops execution what would a good approach to check that and make sure it is always running ?

The command simply prints the log when there is any entry made.

I am on a Ubuntu server 14.04.

Doorknob

You could use nohup combined with &:

nohup cf logs broker-analytics > /var/www/cfbrokerlogs/message.log &

The nohup command causes the program to ignore hangup signals (i.e. those that are sent when closing the terminal), and the & of course runs it in the background.

If you want to make sure it's still running or kill it, you can use ps:

ps ax | grep cf logs broker-analytics

You should then be able to see the process ID, which you can kill if necessary.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How do I run a sudo command needing password input in the background?

분류에서Dev

How to run a program in background and also using && to execute another command

분류에서Dev

How to background a command chain?

분류에서Dev

how to use the background command?

분류에서Dev

how to run closed application In background?

분류에서Dev

How to run a shell script in background?

분류에서Dev

How to setup perl to always run code coverage

분류에서Dev

How to run command on connect to network

분류에서Dev

How to run command as different user

분류에서Dev

How to know the command run by a process?

분류에서Dev

How to run programs and scripts NOT in the background on a remote machine?

분류에서Dev

How to run graphical app in background mode?

분류에서Dev

How to run process in background using gcloud ssh

분류에서Dev

How to run a command or script at screen lock/unlock?

분류에서Dev

How to run a VirtualBox VM from command line?

분류에서Dev

How to run batch file command with elevated permissions?

분류에서Dev

How to run this curl command using Net:HTTP

분류에서Dev

How to include a Java command in ANT to run the project

분류에서Dev

How to run ''top'' command 1 time and exit?

분류에서Dev

How to find the full path of sudo to run a command

분류에서Dev

How to run complicated batch command using "subprocess"

분류에서Dev

How to run bash command with arguments at scheduled time

분류에서Dev

How set command in background,close terminal and get it back to fg?

분류에서Dev

How can I play a song in the background via my command line?

분류에서Dev

Run PHP Script in Background

분류에서Dev

How to automatically run a specific command on Live USB on boot?

분류에서Dev

How do I run an arbitrary shell command from Deno?

분류에서Dev

How detect failure of Web Performance Test run from command line

분류에서Dev

How could I run this as one command in Mongo Shell

Related 관련 기사

  1. 1

    How do I run a sudo command needing password input in the background?

  2. 2

    How to run a program in background and also using && to execute another command

  3. 3

    How to background a command chain?

  4. 4

    how to use the background command?

  5. 5

    how to run closed application In background?

  6. 6

    How to run a shell script in background?

  7. 7

    How to setup perl to always run code coverage

  8. 8

    How to run command on connect to network

  9. 9

    How to run command as different user

  10. 10

    How to know the command run by a process?

  11. 11

    How to run programs and scripts NOT in the background on a remote machine?

  12. 12

    How to run graphical app in background mode?

  13. 13

    How to run process in background using gcloud ssh

  14. 14

    How to run a command or script at screen lock/unlock?

  15. 15

    How to run a VirtualBox VM from command line?

  16. 16

    How to run batch file command with elevated permissions?

  17. 17

    How to run this curl command using Net:HTTP

  18. 18

    How to include a Java command in ANT to run the project

  19. 19

    How to run ''top'' command 1 time and exit?

  20. 20

    How to find the full path of sudo to run a command

  21. 21

    How to run complicated batch command using "subprocess"

  22. 22

    How to run bash command with arguments at scheduled time

  23. 23

    How set command in background,close terminal and get it back to fg?

  24. 24

    How can I play a song in the background via my command line?

  25. 25

    Run PHP Script in Background

  26. 26

    How to automatically run a specific command on Live USB on boot?

  27. 27

    How do I run an arbitrary shell command from Deno?

  28. 28

    How detect failure of Web Performance Test run from command line

  29. 29

    How could I run this as one command in Mongo Shell

뜨겁다태그

보관