<div dir="ltr">Hamisi,<div><br></div><div>The ^I indicates you used a tab when editing the crontab; remove that. And I don't know why the log file is showing "root" followed by a "space", "tab", then command; it should just be the command. Just rewrite the line and avoid tabs.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 5, 2015 at 9:32 AM, Hamisi Jabe 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">
  
    
  
  <div 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 href="mailto:root@x.x.x.x:/srv/vmail/banana.co.tz/" target="_blank">root@x.x.x.x:/srv/vmail/banana.co.tz/</a>
    /home/virtual/<a href="http://banana.co.tz/" target="_blank">banana.co.tz/</a><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<div><div class="h5"><br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <div>On 04/08/2015 09:05 alasiri, Richard
      Manyanza via Linux wrote:<br>
    </div>
    <blockquote 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 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>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" target="_blank">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>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
The Arusha Linux User Group: <a href="http://unix.or.tz" target="_blank">http://unix.or.tz</a>
Linux mailing list
<a href="mailto:Linux@lists.habari.co.tz" target="_blank">Linux@lists.habari.co.tz</a>
<a href="http://lists.habari.co.tz/cgi-bin/mailman/listinfo/linux" target="_blank">http://lists.habari.co.tz/cgi-bin/mailman/listinfo/linux</a>

The Arusha LUG mailing list is generously hosted by Habari Node Ltd: <a href="http://www.habari.co.tz/" target="_blank">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>
  </div></div></div>

<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>