[ALUG] Setting Crons on FreeBSD

Andreas Tauscher ta at geuka.net
Tue Aug 4 19:09:16 EAT 2015


On 08/04/2015 04:51 PM, Hamisi Jabe via Linux wrote:
> Dear All,
> 
> Hope everyone is doing on fine,
> 
> I am trying to set crons on Freebsd to run a script but its not
> executing though when i run the script directly it is running properlly
> from start to end
> 
> Please help
> 
> script directory   without the quotes        "*/etc/rsync.sh*"
> 
> cron job command   without the quotes    "*/*30 * * * *   
> /usr/local/bin/bash /etc/rsync.sh*"

The /etc/contab format is slightly different from the user contab
There are two manpages for crontab.
You might have checked "man crontab" which gives you the man page for
user crontabs from section 1 "executable programs or shell commands"
(first match) and "man 5 crontab" is the manpage for the systemwide
crontab from section 5 "file formats and conventions" you wanted.

There is an important information missing in this line:
The username the script will be executed as which is not requires in
user crontabs.
You tell cron run /etc/rsync.sh as user /usr/local/bin/bash
In the system log you find surely:
"cron: Error: bad username; while reading /etc/crontab"
The */*30 is also wrong this will give an
"cron: (*system*) ERROR Syntax error"
*system* indicates here the system wide crontab. If the error is in a
user crontab then there is the username logged.
Any error making the entire crontab to be ignored.

To run the script every 30 minutes you write */30 * * * *

When your crontab looks like this:
---- SNIP -----
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

*/30 * * * *  <username> /etc/rsync.sh
----- SNAPP -----
And your script is starting with a shebang (#!/usr/local/bin/bash) the
scrip will run every 30 minutes.

Andreas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.habari.co.tz/pipermail/linux/attachments/20150804/4ecfcea3/attachment.pgp>


More information about the Linux mailing list