LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Fundamental automated tasks (https://www.linuxquestions.org/questions/linux-newbie-8/fundamental-automated-tasks-147224/)

dominant 02-17-2004 12:46 PM

Fundamental automated tasks
 
What are the fundamental automated tasks through crontab that a server has to do?

Self-maintenance

Thymox 02-17-2004 07:08 PM

That would depend on what type of server it is. A mail server is going to need to do different things to a file server, a *ahem* CD server, etc, etc. One thing that should be done on all machines, servers or otherwise, is logrotate.

dominant 02-18-2004 03:14 AM

How to do that?
simply

0 3 * * * /sbin/logrotate /var/log/messages

Is that ok?

Thymox 02-18-2004 07:45 AM

My crontab has the following entries:
Code:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
# Minute, hour, day-of-month, month, day-of-week
*/15 * * * * root nice -19 /etc/cron.d/logperms.cron
01 * * * * root nice -n 19 run-parts /etc/cron.hourly
02 16 * * * root nice -n 19 run-parts /etc/cron.daily
22 17 * * 0 root nice -n 19 run-parts /etc/cron.weekly
42 18 1 * * root nice -n 19 run-parts /etc/cron.monthly

The command run-parts basically runs any scripts it find in the given directory. Under /etc/cron.daily I have a script called logrotate that contains
Code:

#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf

The configuration file it uses contains
Code:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own lastlog or wtmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/lastlog {
    monthly
    rotate 1
}

# system-specific logs may be configured here

So there you have it. That is how my logrotate works. The cron entry you have wouldn't work as the command logrotate requires a config file rather than pointing to a directory.

dominant 02-18-2004 08:39 AM

alright, and how logrotate finds where the log files reside?

Thymox 02-18-2004 09:16 AM

In the logrotate.conf file it says that "RPM packages drop log rotation information into this director" and then lists /etc/logrotate.d. In that dir there are yet more files, each a config file corresponding to a service that generates logs that need to be rotated. Try saying that after a few beers :D

Basically, cron reads from the script that tells it to run logrotate. logrotate reads from the logrotate.conf file that tells it to look in /etc/logrotate.d to get information about which logs need rotating.

I doubt very much that /etc/logrotate.d is RPM specific, so it should work on any system.

dominant 02-20-2004 11:59 AM

Alright, i think that suse does logrotation automatically, doesn't it?


All times are GMT -5. The time now is 10:14 PM.