From owner-freebsd-questions@freebsd.org Sat Mar 5 21:23:03 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9C59A13F72 for ; Sat, 5 Mar 2016 21:23:03 +0000 (UTC) (envelope-from brandon.wandersee@gmail.com) Received: from mail-io0-f172.google.com (mail-io0-f172.google.com [209.85.223.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C4411192 for ; Sat, 5 Mar 2016 21:23:03 +0000 (UTC) (envelope-from brandon.wandersee@gmail.com) Received: by mail-io0-f172.google.com with SMTP id n190so96518162iof.0 for ; Sat, 05 Mar 2016 13:23:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=YaG1i9h77o1mF98EjHoTC52ydwtWYbrvKASuLWX7XEY=; b=HDfIAZKgnMQgt0HaN5wGk5PhhDiBTEAOLnE1stZ59hCFglnLHmKnVLBIzbVaatW0O6 XebxTI1n043dY80GEbMzgIXS2Qt9CIF/AAC9b2vqP+Hg90QbN5lsORkfZxwDMNLd1TIR vL+5cx6HQJMH+N4ZlebxoQsnUmhyJgAyYrcPR6T4Hil50ktFDWTRxSy8tXySq0cRJJOW OjdYUYzBkZ+p0AiVXIa/YJ80qqNaNRVGnVctHToUsZJqGArEGj5hxc1/A9U83KZ+97Bo vtkJs1R36L/G21oPV6LXRI0Ca5sf4uccsvP7eMVdPdP1HRJMIFHjdQPbLxfpvF3cPGr+ GoxQ== X-Gm-Message-State: AD7BkJKM6xcaHxFT/iZ1cml+b0ugmfs1ume8vqfMHlh2IajgvU4CTQJtBMmmhO0t1dVumw== X-Received: by 10.107.158.148 with SMTP id h142mr15214341ioe.63.1457212976729; Sat, 05 Mar 2016 13:22:56 -0800 (PST) Received: from WorkBox.Home.gmail.com (174-30-194-239.mpls.qwest.net. [174.30.194.239]) by smtp.gmail.com with ESMTPSA id nh19sm2146537igb.2.2016.03.05.13.22.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Mar 2016 13:22:55 -0800 (PST) References: <430270708.3017333.1457136683088.JavaMail.yahoo.ref@mail.yahoo.com> <430270708.3017333.1457136683088.JavaMail.yahoo@mail.yahoo.com> User-agent: mu4e 0.9.16; emacs 24.5.1 From: Brandon J. Wandersee To: gahn Cc: freebsd-questions@freebsd.org Subject: Re: crontab is not working In-reply-to: <430270708.3017333.1457136683088.JavaMail.yahoo@mail.yahoo.com> Date: Sat, 05 Mar 2016 15:22:57 -0600 Message-ID: <86lh5wpqku.fsf@WorkBox.Home> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Mar 2016 21:23:04 -0000 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 :: ==================================================================