crontab
Ok, so I have been trying to find any tutorials or anything in order to try and create a script for what I want my crontab to do, but I can't find any. So if anyone can answer my question, or refer me to somewhere that can answer my q that would be AMAZING!! :)
So I'm using Tomcat 5 and I want to have the script so that I can rename the current catalina.out file with the current date (Such as catalina_10_27_2008.out), and then create a new catalina.out file where all of the new logs would go into. My current script looks something like this: /sbin/service tomcat5 stop /sbin/service tomcat5 start I want to place the whole moving and creating in between the start and stop so that I have a clear indication of when things are happening. If it helps, the crontab is set so that it updates daily. Any help would be fantastical! Thanks :) |
something like this?
Code:
#!/bin/sh |
thanks for the recommendation for the date. I'll use it! Also, will this automatically recreate a new catalina.out file then? Cause I didn't notice a specific line that created a new file.
Also, I don't know how to use HUP tomcat5. I'm fairly a newb in this whole realm. How does it work? Thanks :) |
Sorry, no that didn't create the new file, for that you probably can just do
touch /path/to/catalina.out And I have no idea if tomcat5 is huppable or not I've never used it (tomcat5 that is). If you read the manpage for tomcat5 check for SIGHUP and if it supports that signal and reopens its log connections when it gets it then you can kill -HUP <pid_of_tomcat5> |
It doesn't seem like tomcat5 can use HUP. (at least I couldn't find anything on it).
so adding touch /path/to/catalina.out would create it and make it so that the output log goes to it rather than the newly moved file? |
Yes as long as you do the stop start stuff.
|
Would it matter if I put the script in this order:
stop tomcat mv catalina touch catalina start tomcat or for touch to work does it have to be: mv catalina touch catalina stop tomcat start tomcat ? (sorry for the million questions. Like I said, super newb here) |
See the logrotate service, it's designed to do this for you.
man logrotate |
All times are GMT -5. The time now is 02:05 AM. |