Loading ...
Sorry, an error occurred while loading the content.

Re: Question on setting up cron job

Expand Messages
  • enventa2000
    Your script is being executed in the cron folder. This means that if the cron script is in /etc/cron.daily then ./ is etc/cron.daily and ../ will become
    Message 1 of 5 , Mar 20, 2004
    • 0 Attachment
      Your script is being executed in the cron folder. This means that if
      the cron script is in /etc/cron.daily then "./" is "etc/cron.daily"
      and "../" will become "/etc".

      "./*/*/access.*" was probably nothing, because "/etc/cron.daily" has
      no subdorectories, and "../web/stats" was "/etc/web/stats".

      To solve this problem, put can this line at the start of the script:
      cd /the_directory_I_usually_run_the_script_from
      Or you can put absolute paths instead of relative.

      I have written some scripts below.

      Your script was like this:

      # non-working cron script
      # /home/sites/companyc/logs/analyze.sh
      for i in ./*/*/access.*
      do webalizer -o ../web/stats/ $i;
      done

      And would become this:

      # relative paths script
      for SITE in /home/sites/* ; do
      cd /home/sites/"$SITE"/logs;
      for j in ./access.*
      do webalizer -o ../web/stats/ $j;
      done;
      done;

      Or perhaps this:

      # absolute paths script
      SITESPATH="/home/sites"
      for i in $SITESPATH/* ; do
      LOGPATH=$SITESPATH$i/logs
      for j in $LOGPATH/access.*
      do webalizer -o $SITESPATH/web/stats/ $j;
      done;
      done;




      --- In webalizer@yahoogroups.com, Bradley Miller <bradmiller@a...>
      wrote:
      > Does anyone have a suggestion for how to get a cron job to work
      with my
      > webalizer? I have my files like this:
      >
      > /home/sites/companya/logs/2003/11/access.01 - day 1, november,
      2003
      > /home/sites/companya/logs/2003/11/access.02 - day 2, november, 200
      >
      > /home/sites/companyb/logs/2003/11/access.01 - day 1, november,
      2003
      > /home/sites/companyb/logs/2003/11/access.02 - day 2, november, 200
      >
      >
      >
      > To clarify that -- the script goes under each web site's
      location. So
      >
      > /home/sites/companya/logs/analyze.sh
      > /home/sites/companyb/logs/analyze.sh
      > /home/sites/companyc/logs/analyze.sh
      >
      >
      > This was my first attempt (analyze.sh):
      >
      > for i in ./*/*/access.*
      > do webalizer -o ../web/stats/ $i;
      > done
      >
      > The problem is I think the script isn't running right when called
      as
      > cronjob. Any suggestions?
    Your message has been successfully submitted and would be delivered to recipients shortly.