FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 07-02-2012, 12:51 PM
Titanus Eramius
 
Default Crontab, Scripting and Syslog

Hi folks
On my webserver I've recently added a log-sorting and presentation
program by the name of Webalizer. To make it run, I've put this line in
the crontab (everything runs as a normal user):

* 04 * * * /home/titanus/scripts/web-log >> /dev/null 2>&1

The line runs every morning at 4, and AFAIK, the /dev/-part should
redirect all but errors to null.

The script is really simple:

#!/bin/sh
webalizer=/usr/bin/webalizer
yesterday_date=$(date -d yesterday +%Y.%m.%d)

# For debugging
# echo "$webalizer"
# echo "$yesterday_date"

if test -e /var/log/apache2/access.$yesterday_date; then
$webalizer /var/log/apache2/access.$yesterday_date
else
echo "Yesterdays log not found. Exiting"
exit 12
fi

exit 0

Now, my question is these lines in syslog:

titanus@aptget:~$ sudo cat /var/log/syslog | grep titanus
Jun 11 04:00:01 aptget /USR/SBIN/CRON[1567]: (titanus) CMD
(/home/titanus/scripts/web-log >> /dev/null 2>&1)
Jun 11 04:01:01 aptget /USR/SBIN/CRON[1572]: (titanus) CMD
(/home/titanus/scripts/web-log >> /dev/null 2>&1)

(One line per minut for an entire hour)

Jun 11 04:59:01 aptget /USR/SBIN/CRON[1879]: (titanus) CMD
(/home/titanus/scripts/web-log >> /dev/null 2>&1)

What do they mean?
As far as I can see, the result of Webalizer is made at 4, not 4:59, so
I suspect the srcipt only runs at 4. The system is a standard Squeeze
with nothing funny or unstable.

Thanks, tit


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120702145106.4aecdf3b@asrock.local.aptget.dk">ht tp://lists.debian.org/20120702145106.4aecdf3b@asrock.local.aptget.dk
 
Old 07-02-2012, 12:59 PM
Darac Marjal
 
Default Crontab, Scripting and Syslog

On Mon, Jul 02, 2012 at 02:51:06PM +0200, Titanus Eramius wrote:
> Hi folks
> On my webserver I've recently added a log-sorting and presentation
> program by the name of Webalizer. To make it run, I've put this line in
> the crontab (everything runs as a normal user):
>
> * 04 * * * /home/titanus/scripts/web-log >> /dev/null 2>&1
>
> The line runs every morning at 4, and AFAIK, the /dev/-part should
> redirect all but errors to null.
>
> The script is really simple:
>
[cut]
>
> Now, my question is these lines in syslog:
>
> titanus@aptget:~$ sudo cat /var/log/syslog | grep titanus
> Jun 11 04:00:01 aptget /USR/SBIN/CRON[1567]: (titanus) CMD
> (/home/titanus/scripts/web-log >> /dev/null 2>&1)
> Jun 11 04:01:01 aptget /USR/SBIN/CRON[1572]: (titanus) CMD
> (/home/titanus/scripts/web-log >> /dev/null 2>&1)
>
> (One line per minut for an entire hour)
>
> Jun 11 04:59:01 aptget /USR/SBIN/CRON[1879]: (titanus) CMD
> (/home/titanus/scripts/web-log >> /dev/null 2>&1)
>
> What do they mean?
> As far as I can see, the result of Webalizer is made at 4, not 4:59, so
> I suspect the srcipt only runs at 4. The system is a standard Squeeze
> with nothing funny or unstable.

These lines are cron telling you what it's running. Note that your
crontab line states:

# min hr dom mon dow command
> * 04 * * * /home/titanus/scripts/web-log >> /dev/null 2>&1

That is, every minute during hour 4, on every day of every month (that
being every day of the week), the command is run.

Presumably, webalizer writes its output to the same place each time, so
that is why you're only seeing the output of the 4:59 run.

Try changing your crontab to read:

# min hr dom mon dow command
0 04 * * * /home/titanus/scripts/web-log >> /dev/null 2>&1

This will run at 4:00 every day, and is probably what you meant.
 
Old 07-02-2012, 01:47 PM
Titanus Eramius
 
Default Crontab, Scripting and Syslog

snip

> # min hr dom mon dow command
> > * 04 * * * /home/titanus/scripts/web-log >> /dev/null 2>&1
>
> That is, every minute during hour 4, on every day of every month (that
> being every day of the week), the command is run.
>
> Presumably, webalizer writes its output to the same place each time,
> so that is why you're only seeing the output of the 4:59 run.
>
> Try changing your crontab to read:
>
> # min hr dom mon dow command
> 0 04 * * * /home/titanus/scripts/web-log >> /dev/null 2>&1
>
> This will run at 4:00 every day, and is probably what you meant.
>
Yes it is.
I'll try and set it and return tommorrow.

Cheers


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120702154735.1ecfc379@asrock.local.aptget.dk">ht tp://lists.debian.org/20120702154735.1ecfc379@asrock.local.aptget.dk
 
Old 07-02-2012, 02:07 PM
Chris Davies
 
Default Crontab, Scripting and Syslog

Titanus Eramius <titanus@aptget.dk> wrote:
> * 04 * * * /home/titanus/scripts/web-log >> /dev/null 2>&1

> The line runs every morning at 4, and AFAIK, the /dev/-part should
> redirect all but errors to null.

No.

1. This runs every minute while the hour is 4. If you want the script
to run only a 4am, you need to specify a zero minute value too

2. The ">> /dev/null 2>&1" tells cron to thow away not just errors but
also all normal output. If you want to lose information written to stderr
(typically errors), then you need "2> /dev/null"

0 4 * * * /home/titanus/scripts/web-log 2>/dev/null

Chris


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: iim8c9x3dg.ln2@news.roaima.co.uk">http://lists.debian.org/iim8c9x3dg.ln2@news.roaima.co.uk
 

Thread Tools




All times are GMT. The time now is 07:28 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org