Could not lock file /dev/stdin for reading

I'm setting up a Musicbrainz mirror server on FreeBSD. Everything works except the provided replication shell script.
This is the code that is failing:

Bash:
logrotate /dev/stdin <<EOF
/var/logs/mirror.log {
   daily
   rotate 30
}
EOF

It fails on the first line with the error message that the shell "Could not lock file /dev/stdin for reading".

I tried it on Linux and it works just fine. How can I make this work on FreeBSD?
 
What is the "logrotate" command that is being run here? Where did you install it from? What does it do? How is one supposed to use it? It is not part of the base FreeBSD install.

Suggestion: Find the documentation for logrotate, and read it.
 
The obvious fix is to create a logrotate conf file and pass that into it vs. redirecting stdin but it does work under Linux the way it's written and I just wonder how I can make it work using FreeBSD.

BTW if logrotate isn't part of standard FreeBSD just how are logs rotated? Maybe that's what I should be using.
 
It's shell's heredoc style around the logrotate command that doesn't exist in FreeBSD base (it is in ports though). Natively FreeBSD uses newsyslog(8). With that you need different syntax to one you have in that script.
 
If I replace logrotate with the cat command it works. It seems like logrotate is trying to place some kind of a lock on the input file (in this case it's stdin) and that must not work in FreeBSD. I'll try using newsyslog(8) instead.
 
You could debug what is going on: Instead of running logrotate (thanks to getopt for the link to documentation!) on the here document in /dev/stdin, copy that content into a file, and run logrotate on that file. Then run logrotate using truss, and look at all the system calls it issues. As you said, most likely logrotate locks its input file while running (which might be a good idea), and that may not be possible on /dev/stdin.
 
Back
Top