<div dir="ltr">Hamisi, adding to your confusion (and hopefully clarity):<div><br></div><div>Are you using the root crontab or a normal user's crontab?</div><div><br></div><div>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:</div><div><br></div><div>*/30 * * * * root /usr/local/bin/bash /etc/rsync.sh</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 4, 2015 at 7:09 PM, Andreas Tauscher via Linux <span dir="ltr"><<a href="mailto:linux@lists.habari.co.tz" target="_blank">linux@lists.habari.co.tz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 08/04/2015 04:51 PM, Hamisi Jabe via Linux wrote:<br>
> Dear All,<br>
><br>
> Hope everyone is doing on fine,<br>
><br>
> I am trying to set crons on Freebsd to run a script but its not<br>
> executing though when i run the script directly it is running properlly<br>
> from start to end<br>
><br>
> Please help<br>
><br>
</span>> script directory   without the quotes        "*/etc/rsync.sh*"<br>
><br>
> cron job command   without the quotes    "*/*30 * * * *<br>
> /usr/local/bin/bash /etc/rsync.sh*"<br>
<br>
The /etc/contab format is slightly different from the user contab<br>
There are two manpages for crontab.<br>
You might have checked "man crontab" which gives you the man page for<br>
user crontabs from section 1 "executable programs or shell commands"<br>
(first match) and "man 5 crontab" is the manpage for the systemwide<br>
crontab from section 5 "file formats and conventions" you wanted.<br>
<br>
There is an important information missing in this line:<br>
The username the script will be executed as which is not requires in<br>
user crontabs.<br>
You tell cron run /etc/rsync.sh as user /usr/local/bin/bash<br>
In the system log you find surely:<br>
"cron: Error: bad username; while reading /etc/crontab"<br>
The */*30 is also wrong this will give an<br>
"cron: (*system*) ERROR Syntax error"<br>
*system* indicates here the system wide crontab. If the error is in a<br>
user crontab then there is the username logged.<br>
Any error making the entire crontab to be ignored.<br>
<br>
To run the script every 30 minutes you write */30 * * * *<br>
<br>
When your crontab looks like this:<br>
---- SNIP -----<br>
SHELL=/bin/sh<br>
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br>
<br>
*/30 * * * *  <username> /etc/rsync.sh<br>
----- SNAPP -----<br>
And your script is starting with a shebang (#!/usr/local/bin/bash) the<br>
scrip will run every 30 minutes.<br>
<br>
Andreas<br>
<br>
<br>_______________________________________________<br>
The Arusha Linux User Group: <a href="http://unix.or.tz" rel="noreferrer" target="_blank">http://unix.or.tz</a><br>
Linux mailing list<br>
<a href="mailto:Linux@lists.habari.co.tz">Linux@lists.habari.co.tz</a><br>
<a href="http://lists.habari.co.tz/cgi-bin/mailman/listinfo/linux" rel="noreferrer" target="_blank">http://lists.habari.co.tz/cgi-bin/mailman/listinfo/linux</a><br>
<br>
The Arusha LUG mailing list is generously hosted by Habari Node Ltd: <a href="http://www.habari.co.tz/" rel="noreferrer" target="_blank">http://www.habari.co.tz/</a><br>
<br>
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.<br></blockquote></div><br></div>