Showing posts with label crontab. Show all posts
Showing posts with label crontab. Show all posts

Wednesday, 4 November 2009

Howto: Adjust updatedb.mlocat to a sensible time.


All credit for this goes to This Blog Entry where I found this helpful information.

If you are an early riser like myself (well, occasionally at least) then you may notice your PC grinding away on its harddrives like a mad thing. I have around 3TB of storage so the problem is exacerbated somewhat. The process to blame is updatedb.mlocat which runs between 6am and 7am, I want a quiet morning with my coffee so I am going to show you how to move it to between 3am and 4am

The job parameters are listed in /etc/cron.daily/mlocate. We don't edit anything here, its just for reference.

#! /bin/sh

set -e

[ -x /usr/bin/updatedb.mlocate ] || exit 0

# See ionice(1)
if [ -x /usr/bin/ionice ]; then
IONICE=”/usr/bin/ionice -c3″
fi

$IONICE /usr/bin/updatedb.m

The files in /etc/cron.daily are kicked off by /etc/crontab, not by root’s crontab. For some reason, Ubuntu’s default install runs this process around 6am. Changing this file allowed me to make the job run at 3am. Here we change the hour time to 3 instead of 6, so you will need a sudo gedit or something to adjust this... carefully.. sudo gedit /etc/crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don’t have to run the `crontab’
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root cd / && run-parts –report /etc/cron.hourly
25 3 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
47 3 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.weekly )
52 3 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.monthly )
#


updatedb can be configured to ignore certain paths - since my machine has a number of drives used for backups, I wanted to exclude those from the updatedb job. I accomplished this by editing /etc/updatedb.conf and adding to the PRUNEPATHS listing. Adding paths to the PRUNEPATHS option instructs updatedb to exclude those paths from indexing.

PRUNE_BIND_MOUNTS=”yes”
PRUNEPATHS=”/tmp /var/spool /media /mnt/backup”
PRUNEFS=”NFS nfs nfs4 afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre_lite tmpfs usbfs udf rpc_pipefs”

Sunday, 31 August 2008

Install and use ClamAV for linux anti virus

Install Clamav with either Synaptic or apt-get/aptitude.

To update the definitions use:

sudo freshclam

scanning files is as simple then as calling clamscan with the -r or --recursive flag and a path, if the path is omitted then it will scan at the current path:

clamscan -r /home/subbass
or clamscan -r

If you would rather only see infected files then use the -i or --infected flag:

clamscan -ri /home/subbass
or clamscan -ri

If you wish to scan every file on the system you may have to run clamscan with sudo, as running without it clamscan can only read files the user running it can access.

sudo clamscan -ri /

This would check every file on the system recursively and report only infected files.

You can schedule clamscan using cron or for the odd one off scans using the "at" command, such as:
at 3:30 tomorrow
at>clamscan -i /home/user > mail user@example.com
at>
job 3 at 2005-04-28 03:30
This would perform the scan at 3:30am later that night and mail the results to the defined address. To add a regular cron job try the following:

nano crontab -e

Then enter the following line at the bottom of the file

00 00 * * * sudo clamscan -r /location_of_files_or_folders
Save the file and exit.