WebFaction
Community site: login faq

I've compiled a custom setup to serve my pages.

I was wondering if I need to set up a cron job or something to rotate or clear my custom application logs, or if that is taken care of since I've placed them into the /home/username/logs/user folder.

On a similar note, I've set up cron jobs to "run" nginx and php-fpm every 20 minutes. I accomplish that by just running the command to start them. Is there a way to check if they are already running? I suppose I should just set up a shell script that does:

if ((ps -u username | grep nginx) == '')
    nginx
if ((ps -u username | grep php-fpm) == '')
    php-fpm

Any tips on that front? I'm not an expert shell scripter, so I'm sure the code above wouldn't work as is, but is that a more proper way to ensure my processes are running? Or is it fine to just run them and let them find out themselves.

I only ask because I'm logging everything into a cron.log in my home directory, and it's just showing stuff along the lines of "error application already listening on port" or "Another FPM instance seems to be listening...". I'm not sure if that could ever cause an issue.

asked 20 Dec '12, 19:02

stoolio
135
accept rate: 0%

edited 20 Dec '12, 19:02


Regarding the logs, if you place them in ~/logs, they should be rotated daily.

Regarding creating a watchdog script to monitor your processes, which you run every 20 minutes, and only start the application if it's not already running, I would recommend the method described on this related community post. Using a shell script as you have suggested is the correct method, and that topic provides a robust example which you can use.

Hope that helps!

permanent link

answered 20 Dec '12, 19:27

ryans ♦♦
5.0k93260
accept rate: 43%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×186
×81
×47

question asked: 20 Dec '12, 19:02

question was seen: 2,590 times

last updated: 20 Dec '12, 19:27

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM