cron quarterly - Unix

This is a discussion on cron quarterly - Unix ; Hi, every three months I run a postgres report on our CentOS 4 server to extract statistics from the database for the preceeding quarter, which I then email to the managers. I have written a script that can be run ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: cron quarterly

  1. cron quarterly

    Hi, every three months I run a postgres report on our CentOS 4 server
    to extract statistics from the database for the preceeding quarter,
    which I then email to the managers. I have written a script that can
    be run with a single command logged in as root, to automatically work
    out the dates required, run the query, then email the results. Is it
    possible to schedule my script to run at the beginning of each
    financial quarter without my intervention (using cron)?

  2. Re: cron quarterly

    On 25 May, 14:20, leehanken wrote:
    > Hi, every three months I run a postgres report on our CentOS 4 server
    > to extract statistics from the database for the preceeding quarter,
    > which I then email to the managers. I have written a script that can
    > be run with a single command logged in as root, to automatically work
    > out the dates required, run the query, then email the results. Is it
    > possible to schedule my script to run at the beginning of each
    > financial quarter without my intervention (using cron)?


    To answer my own question, it looks like I either put 4 separate
    entries in the crontab, or
    run the following on the first of each month:

    case `date +%m` in
    01|04|07|10) executescript ;;
    esac

  3. Re: cron quarterly

    On Sun, 25 May 2008, in the Usenet newsgroup comp.unix.admin, in article
    <2818f438-ec32-4d20-bda7-157b99742704@x41g2000hsb.googlegroups.com>,
    leehanken wrote:

    NOTE: Posting from groups.google.com (or some web-forums) dramatically
    reduces the chance of your post being seen. Find a real news server.

    >On 25 May, 14:20, leehanken wrote:
    >> Hi, every three months I run a postgres report on our CentOS 4 server
    >> to extract statistics from the database for the preceeding quarter,
    >> which I then email to the managers.


    OK - CentOS should be vixie-cron - so 'man 5 crontab'

    >> I have written a script that can be run with a single command logged
    >> in as root, to automatically work out the dates required, run the
    >> query, then email the results. Is it possible to schedule my script
    >> to run at the beginning of each financial quarter without my
    >> intervention (using cron)?


    So that would go in either "root's" crontab (as root, 'crontab -e') or
    the system crontab (/etc/crontab). Be sure to test the script,
    because the environment in cron is a heck of a lot more restrictive
    than as root or a user. Use the 'set' command to see what your
    environment looks like, and make a cron job to run that same command,
    redirecting the results into a file.

    [compton ~]$ wc *environment
    20 19 236 cron.environment
    41 50 585 nobody.environment
    51 71 875 root.environment
    39 46 1377 user.environment
    151 186 3073 total
    [compton ~]$

    >To answer my own question, it looks like I either put 4 separate
    >entries in the crontab,


    man 5 crontab

    0 1 1 1,4,7,10 * /path/to/executescript

    would run the job a 01:00 on the first of {Jan|Apr|Jul|Oct}. If that
    were the _system_ crontab rather than root's, you'd have to add the
    'user to run as' between the star and the command. It's in the man
    pages.

    Old guy

+ Reply to Thread