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.

2
  • 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? Commented Jan 26, 2015 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 Commented Jan 27, 2015 at 12:17

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .