Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 05 Mar 2016 15:22:57 -0600
From:      Brandon J. Wandersee <brandon.wandersee@gmail.com>
To:        gahn <ipfreak@yahoo.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: crontab is not working
Message-ID:  <86lh5wpqku.fsf@WorkBox.Home>
In-Reply-To: <430270708.3017333.1457136683088.JavaMail.yahoo@mail.yahoo.com>
References:  <430270708.3017333.1457136683088.JavaMail.yahoo.ref@mail.yahoo.com> <430270708.3017333.1457136683088.JavaMail.yahoo@mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help

gahn via freebsd-questions writes:

> hi:
> i am trying to test a crontab job for snmpwalk but it is not working:
> here is crontab:
> */1  * * * * root /root/snmpwalk.sh
>
> for the script, it is very simple:
> #!/usr/local/bin/bash
>
> /usr/local/bin/snmpwalk -v 2c -c public 100.10.10.10
> from the log, i can see this
>
> Mar 4 15:22:00 snails /usr/sbin/cron[88515]: (operator) CMD (/usr/libexec/save-entropy)
> Mar 4 15:22:00 snails /usr/sbin/cron[88516]: (root) CMD (root^I/root/snmpwalk.sh)
> Mar 4 15:23:00 snails /usr/sbin/cron[88531]: (root) CMD (root^I/root/snmpwalk.sh)
> Mar 4 15:24:00 snails /usr/sbin/cron[88534]: (root) CMD (root^I/root/snmpwalk.sh)
> thanks.
>

This is a very minor nitpick, and unlikely to be the cause of the
problem, but there's nothing in that script that requires Bash. Use
`#!/bin/sh` instead. It's the default execution shell for the system. In
fact, since you specify the full path to snmpwalk in the script you
could remove the shebang altogether and just run `sh /root/snmpwalk.sh`
in the cron job.

Though it's probably not the solution (I assume you have Bash
installed), using the native shell rather than a third-party shell would
at least rule out a possible cause.

-- 
=================================================================
   		      :: Brandon Wandersee ::
                  :: brandon.wandersee@gmail.com ::
==================================================================



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86lh5wpqku.fsf>