[ALUG] Setting Crons on FreeBSD

Richard Manyanza 1.liseki at gmail.com
Tue Aug 4 21:05:49 EAT 2015


Hamisi, adding to your confusion (and hopefully clarity):

Are you using the root crontab or a normal user's crontab?

Your script is in /etc; does it need root access to run? If so you have to
put your cron entry in the root crontab (/etc/crontab). The format of this
crontab, unlike a normal user's crontab, includes a user parameter before
the command and should read:

*/30 * * * * root /usr/local/bin/bash /etc/rsync.sh


On Tue, Aug 4, 2015 at 7:09 PM, Andreas Tauscher via Linux <
linux at lists.habari.co.tz> wrote:

> 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
>
>
> _______________________________________________
> The Arusha Linux User Group: http://unix.or.tz
> Linux mailing list
> Linux at lists.habari.co.tz
> http://lists.habari.co.tz/cgi-bin/mailman/listinfo/linux
>
> The Arusha LUG mailing list is generously hosted by Habari Node Ltd:
> http://www.habari.co.tz/
>
> The above comments and data are owned by whoever posted them (including
> attachments if any). The mailing list host is not responsible for them in
> any way.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.habari.co.tz/pipermail/linux/attachments/20150804/9e503623/attachment.html>


More information about the Linux mailing list