1

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.

  • Do you want to run the command from the time you start it explicitly until you tell it to stop? Or do you want to run it all the time from boot? – Gilles Jan 26 '15 at 19:59
  • Yes I wanted to run it all the time even on boot until I stop it myself. I tried nohup cf logs broker-analytics > /var/www/cfbrokerlogs/message.log & but that would stop on boot – user3846091 Jan 27 '15 at 12:17
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.