<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Dear Adreas,<br>
<br>
<b><br>
</b>I was running this as a global cron added on the<b> /etc/crontab</b>
file<br>
<br>
*/10 * * * * root /usr/local/bin/bash
/etc/rsync.sh<br>
<br>
<br>
<br>
<br>
<big><b>The Script file content rsync.sh</b></big>
__________________________________________________________________________________________________<br>
<br>
#!/usr/local/bin/bash<br>
rsync -v --archive --delete <a class="moz-txt-link-abbreviated" href="mailto:root@x.x.x.x:/srv/vmail/banana.co.tz/">root@x.x.x.x:/srv/vmail/banana.co.tz/</a>
/home/virtual/banana.co.tz/<br>
cd /home/<br>
chown -R vscan:vscan virtual<br>
___________________________________________________________________________________________________<br>
<br>
<br>
When i tail the /var/log/cron file i get the results below <br>
<br>
tail -f /var/log/cron<br>
Aug 5 12:00:00 mx3 /usr/sbin/cron[17249]: (root) CMD (
/usr/libexec/atrun)<br>
Aug 5 12:00:00 mx3 /usr/sbin/cron[17248]: (root) CMD ( newsyslog)<br>
<b>Aug 5 12:00:00 mx3 /usr/sbin/cron[17250]: (root) CMD (root
^I/usr/local/bin/bash /etc/rsync.sh)</b><br>
Aug 5 12:01:00 mx3 /usr/sbin/cron[17283]: (*system*) RELOAD
(/etc/crontab)<br>
Aug 5 12:05:00 mx3 /usr/sbin/cron[17435]: (root) CMD (
/usr/libexec/atrun)<br>
Aug 5 12:10:00 mx3 /usr/sbin/cron[17508]: (root) CMD (
/usr/libexec/atrun)<br>
<b>Aug 5 12:10:00 mx3 /usr/sbin/cron[17507]: (root) CMD
(^I/usr/local/bin/bash /etc/rsync.sh)</b><br>
<b>Aug 5 12:10:00 mx3 /usr/sbin/cron[17509]: (root) CMD (root
^I/usr/local/bin/bash /etc/rsync.sh)</b><br>
Aug 5 12:11:00 mx3 /usr/sbin/cron[17622]: (operator) CMD
(/usr/libexec/save-entropy)<br>
Aug 5 12:15:00 mx3 /usr/sbin/cron[17699]: (root) CMD (
/usr/libexec/atrun)<br>
<br>
<br>
<br>
May be you can check the results above if its the script problem or,
because if i run the command using:-<br>
<br>
<b>bash /etc/rsync.sh </b><br>
<b>sh /etc/rsync.sh</b><b><br>
/usr/local/bin/bash /etc/rsync.sh</b><br>
<br>
<br>
It is running successfully from start to end<br>
<br>
<br>
Thanks<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 04/08/2015 09:05 alasiri, Richard
Manyanza via Linux wrote:<br>
</div>
<blockquote
cite="mid:CALqRJvkP9KWahXoRP06OaPDHyn63=LOLbGiYECzoYnk-uiOP7w@mail.gmail.com"
type="cite">
<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
moz-do-not-send="true"
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 moz-do-not-send="true"
href="http://unix.or.tz" rel="noreferrer" target="_blank">http://unix.or.tz</a><br>
Linux mailing list<br>
<a moz-do-not-send="true"
href="mailto:Linux@lists.habari.co.tz">Linux@lists.habari.co.tz</a><br>
<a moz-do-not-send="true"
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 moz-do-not-send="true"
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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
The Arusha Linux User Group: <a class="moz-txt-link-freetext" href="http://unix.or.tz">http://unix.or.tz</a>
Linux mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Linux@lists.habari.co.tz">Linux@lists.habari.co.tz</a>
<a class="moz-txt-link-freetext" href="http://lists.habari.co.tz/cgi-bin/mailman/listinfo/linux">http://lists.habari.co.tz/cgi-bin/mailman/listinfo/linux</a>
The Arusha LUG mailing list is generously hosted by Habari Node Ltd: <a class="moz-txt-link-freetext" href="http://www.habari.co.tz/">http://www.habari.co.tz/</a>
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.</pre>
</blockquote>
<br>
</body>
</html>