I have never done a cron before so just want to check how to do it properly. I need to do this daily
What I want to do is run /usr/bin/freshclam then if posible write something to a file with a time stamp that says this has been done.
Is it as simple as going to /etc/cron.daily creating a new file and saving it as antivirusupdate.sh
with this in
#! bin/bash
/usr/bin/freshclam
I dont know how to go about making a logfile for this and writing to it.
#Notice the added ‘/’ in the line above… definitely needed.
FRESHCLAMLOG=/var/log/freshclam.log #change as needed
echo date +%s >> $FRESHCLAMLOG
echo ‘Attempting to start /usr/bin/freshclam…’ >> $FRESHCLAMLOG
/usr/bin/freshclam
if $? = 0 ] ; then
echo ‘No errors returned.’ >> $FRESHCLAMLOG
else
echo ‘Something may have gone wrong.’ >> $FRESHCLAMLOG
fi
echo ‘Cron job attempt ending.’ >> $FRESHCLAMLOG
</quote>
Obviously this may be more-verbose than you’d like it to be, but it’s
something to get you going. I have not verified the syntax at all but
imagine it’s fairly close. If you get error post back and we’ll clean
it up if needed.
Good luck.
BishopVLE wrote:
> I have never done a cron before so just want to check how to do it
> properly. I need to do this daily
> What I want to do is run /usr/bin/freshclam then if posible write
> something to a file with a time stamp that says this has been done.
>
> Is it as simple as going to /etc/cron.daily creating a new file and
> saving it as antivirusupdate.sh
>
> with this in
> Code:
> --------------------
>
> #! bin/bash
> /usr/bin/freshclam
> --------------------
>
>
> I dont know how to go about making a logfile for this and writing to
> it.
>
> Also is that all I have to do?
>
> TIA
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
Thanks, I have done as you said. How do I try to test this? I have gone to the termial and tried to run the script as root /etc/cron.daily/antivirusupdate.sh
but i get a error permission denied.
Or will i have to wait till suse tries to run the script
BishopVLE wrote:
> Thanks, I have done as you said. How do I try to test this? I have gone
> to the termial and tried to run the script as root
> /etc/cron.daily/antivirusupdate.sh
> but i get a error permission denied.
>
> Or will i have to wait till suse tries to run the script
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
Thanks thaqt works a treat. i got concerned the other day when i tried running it more than once a day it through up a error.
But if i just leave it to its own devices it seams to be fine.
Hmm, you realise that freshclam is usually run as a daemon from the script /etc/init.d/freshclam to update the database every 3 hours or so (IIRC). It will even poke clamd to tell it that the virus definitions have been updated. So you don’t need to write your own job for it, just start the freshclam service and make sure it’s enabled at boot.
>
> BishopVLE;1934984 Wrote:
>> I have never done a cron before so just want to check how to do it
>> properly. I need to do this daily
>> What I want to do is run /usr/bin/freshclam then if posible write
>> something to a file with a time stamp that says this has been done.
>>
>> Is it as simple as going to /etc/cron.daily creating a new file and
>> saving it as antivirusupdate.sh
>>
>> with this in>
> Code:
> --------------------
> > >
> > #! bin/bash
> > /usr/bin/freshclam
> --------------------
>> >
>>
>> I dont know how to go about making a logfile for this and writing to
>> it.
>>
>> Also is that all I have to do?
>>
>> TIA
>
> Hmm, you realise that freshclam is usually run as a daemon from the
> script /etc/init.d/freshclam to update the database every 3 hours or so
> (IIRC). It will even poke clamd to tell it that the virus definitions
> have been updated. So you don’t need to write your own job for it, just
> start the freshclam service and make sure it’s enabled at boot.
>
>
BishopVLB;
In addition to Ken’s comment, you can configure freshclam,
via: /etc/freshclam.conf, to write to a log file with a time stamp. A typical
log entry would look like:
Wed Feb 4 05:28:23 2009 -> Received signal: wake up
Wed Feb 4 05:28:23 2009 -> Max retries == 5
Wed Feb 4 05:28:23 2009 -> ClamAV update process started at Wed Feb 4
05:28:23 2009
Wed Feb 4 05:28:23 2009 -> Using IPv6 aware code
Wed Feb 4 05:28:23 2009 -> Querying current.cvd.clamav.net
Wed Feb 4 05:28:23 2009 -> TTL: 900
Wed Feb 4 05:28:23 2009 -> Software version from DNS: 0.94.2
Wed Feb 4 05:28:23 2009 -> main.cvd version from DNS: 49
Wed Feb 4 05:28:23 2009 -> main.cld is up to date (version: 49, sigs: 437972,
f-level: 35, builder: sven)
Wed Feb 4 05:28:23 2009 -> daily.cvd version from DNS: 8950
Wed Feb 4 05:28:23 2009 -> Retrieving
http://db.us.clamav.net/daily-8950.cdiff
Wed Feb 4 05:28:23 2009 -> Trying to download
http://db.us.clamav.net/daily-8950.cdiff (IP: 207.57.106.31)
Wed Feb 4 05:28:25 2009 -> Downloading daily-8950.cdiff [100%]
Wed Feb 4 05:28:25 2009 -> cdiff_apply: Parsed 4619 lines and executed 4619
commands
Wed Feb 4 05:28:25 2009 -> daily.cld updated (version: 8950, sigs: 72593,
f-level: 38, builder: ccordes)
Wed Feb 4 05:28:25 2009 -> Database updated (510565 signatures) from
db.us.clamav.net (IP: 207.57.106.31)
Wed Feb 4 05:28:25 2009 -> Clamd successfully notified about the update.
Wed Feb 4 05:28:25 2009 -> --------------------------------------
–
P. V.
“We’re all in this together, I’m pulling for you.” Red Green