LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-19-2016, 05:55 AM   #1
tonj
Member
 
Registered: Sep 2008
Posts: 529

Rep: Reputation: 37
log file stuck at 0 bytes after logrotate


I have ffmpeg running and encoding a video stream, the process creates a log file - /var/log/stream.log. I start the stream with:
# /etc/init.d/stream start

This is the (beginning) contents of /etc/init.d/stream:

Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides:          stream
# Required-Start:    $local_fs $network $named $time $syslog
# Required-Stop:     $local_fs $network $named $time $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       start ffmpeg
### END INIT INFO

SCRIPT="/usr/bin/ffmpeg -i 'rtsp://  <rest of command here> "

RUNAS=root

PIDFILE=/var/run/stream.pid
LOGFILE=/var/log/stream.log

<snip-rest-of-file>
I have a logrotate file for stream.log to stop it getting too big:
/etc/logrotate.d/stream

Code:
/var/log/stream.log {
    missingok
    notifempty
    size 2000k
    weekly
    create 0600 root root
    mail <my-email-address>
}
the problem is although the log file is rotating properly the new log file generated is stuck on empty (0 bytes), which is no good for troubleshooting. Is there a way around this?
 
Old 04-19-2016, 07:07 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 5,990
Blog Entries: 16

Rep: Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545Reputation: 3545
That 600 mode might be doing the damage. Is the log file written by some kind of daemon or by a user-launched program? Because if the program runs in your name, it needs write access to the log. 666 might be better. Or, if that's too insecure, transfer the log file to your group and you could use 660.
 
Old 04-19-2016, 07:38 AM   #3
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 7,231

Rep: Reputation: Disabled
You need to send SIGHUP to your process after the logfile is rotated.
 
Old 04-19-2016, 09:54 AM   #4
tonj
Member
 
Registered: Sep 2008
Posts: 529

Original Poster
Rep: Reputation: 37
@emerson: ok thanks but how would one do that?
 
Old 04-19-2016, 10:06 AM   #5
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 7,231

Rep: Reputation: Disabled
This is usually done by your logrotate application, see the documentation for it.
 
Old 04-19-2016, 10:22 AM   #6
tonj
Member
 
Registered: Sep 2008
Posts: 529

Original Poster
Rep: Reputation: 37
ok thanks I solved it by putting this into /etc/logrotate.d/stream
Quote:
postrotate
/etc/init.d/stream stop
endscript
once the stream has stopped I let monit restart it.
 
Old 04-19-2016, 10:24 AM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 7,231

Rep: Reputation: Disabled
See examples on this man page https://www.freebsd.org/cgi/man.cgi?...manpath=RedHat
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] logrotate logs to log.1 instead of to default log yzT! Linux - Server 1 10-01-2014 04:15 AM
how to configure logrotate utility to limit the size of log file prabhakar1234 Linux - Software 1 07-07-2014 09:30 AM
[SOLVED] Logrotate Custom Log File Problem clozarks Linux - Newbie 8 04-20-2012 10:43 AM
does logrotate set size to 1048576 bytes by default if no size is specified? finebanana Red Hat 0 01-22-2009 01:10 AM
Log Rotation using Logrotate keysorsoze Linux - General 4 04-13-2007 03:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration