Helpful Information
 
 
Category: BSD Help
Cron ??? How to make sure it's working

hello there,

I have a script that needs to be run each day called whatever.sh

How do I -

1) see if it is already running
2) If it ain't running, how do I start it ?

any help will be greatly appreciated,

cheers,

Adam

1) Check the process (ps aux).
Check your /var/cron/log file.

2) It's started automatically on boot by default.

/etc/defaults/rc.conf:

cron_enable="YES"

If you put cron_enable="NO" to /etc/rc.conf, then of course, /etc/rc.conf overrides /etc/defaults/rc.conf, then NO.
If you don't pipe the output to /dev/null, cron by default will send the output to your root email account, if it's a root crontab.

Thanks a lot for that - cron seems to be running OK,

one question though, I have found some files in the /var/log directory but am unsure if they're the one's I need
/var/log/cron
/var/log/cron.0.gz
/var/log/cron.1.gz
/var/log/cron.2.gz
/var/log/cron.3.gz

I tried to open these files with no luck. Am I doing it right and looking in the right place.

cheers,

Adam

First off, sorry for the incorrect info I provided previously. Cron's log should be /var/log/cron instead of /var/cron/log. I got mixed up with NetBSD and OpenBSD because /var/cron/log is the location for them.

>> I tried to open these files with no luck

/var/log/cron is the current one. The ones with *gz extension are rotated by newsyslog (/etc/newsyslog.conf). That said, they are old cron logs. You can view them by zcat, not cat.

Thanks very much for that, much appreciated.

Is it possible to search those logs to see if and when the script sophos.sh was run ?

cheers,

Adam

To search? You should just check your current one /var/log/cron. Just tail it if you don't like cat.

>> when the script sophos.sh was run ?

You mean for the old logs? Then just run: zcat cron*gz | grep "sophos.sh" | awk '{print $1,$2,$3}' >> /root/sophos_log and view your sophos_log any way you want.










privacy (GDPR)