Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have following logrotate configuration file

/home/application/*/shared/log/*.log {
  daily
  rotate 10
  missingok
  nocompress
  notifempty
  copytruncate
  sharedscripts
  postrotate
    echo "Hi....." 
    /home/application/test.sh > /home/application/test_bash.log 2>&1
    echo "By....."
  endscript
}

/home/application/test.sh currently content is following (I try in shell script create dummy file too, but no success)

#!/bin/sh

echo "=============================================="

When I run logrotate all files are successfully rotated but test.sh script is not executed

Logrotate potput looks following:

running postrotate script running script with arg /home/application//shared/log/.log : " echo "Hi....." /home/application/test.sh > /home/application/test_bash.log 2>&1 echo "By....." "

/home/application/test_bash.log log file is not created.

I even try simple such example

/home/application/*/shared/log/*.log { 
  daily 
  rotate 10 
  missingok 
  nocompress 
  notifempty 
  copytruncate 
  sharedscripts 
  postrotate 
    mkdir /home/application/demo_v2/shared/log/arch 
  endscript 
}

Why logrotate is not executing my shell script? What I am doing incorrect?

share|improve this question
    
Please show us the full output of logrotate -v -f /etc/logrotate.d/<your_application>? –  quanta Jul 31 '12 at 16:35
    
Thanks you give me necessary hint. I was running lograte with d option logrotate -dv -f /etc/logrotate.d/<your_application> Without d all was as expected –  user1124133 Jul 31 '12 at 18:57

1 Answer 1

Logrotate does not have a magical TTY attached; where did you expect this output to be written to ?

One would normally run a script that redirects its output to a dedicate dlog, and avoid outputting anything on stdout; you seem to have confused several concepts above.

Perhaps, if we knew what it is you want to actually do with this logrotate script, somebody could help.

share|improve this answer
    
I even try following postrotate script. No success /home/application/*/shared/log/*.log { daily rotate 10 missingok nocompress notifempty copytruncate sharedscripts postrotate mkdir /home/application/demo_v2/shared/log/arch endscript } When I run: logrotate -dvf /etc/logrotate.d/application_log_conf I got Response: running postrotate script running script with arg /home/application/*/shared/log/*.log : " /home/application/test.sh " –  user1124133 Jul 31 '12 at 14:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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