Re: cron quarterly



On Sun, 25 May 2008, in the Usenet newsgroup comp.unix.admin, in article
<2818f438-ec32-4d20-bda7-157b99742704@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
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 <leehan...@xxxxxxxxx> 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
.



Relevant Pages

  • Re: Running DBI, ODBC in the crontab
    ... Run the following lines in both the command line and crontab: ... Any of the paths that are missing in cron ... This communication is issued by UBS AG or an affiliate by the ...
    (perl.dbi.users)
  • SUMMARY: cron entry: nth day of every month?
    ... cron can not handle this with its own syntax. ... 21st but "command" only runs if the output of the "date" command ... What I would suggest is rather than embedding the logic in each script ... The answer is it is _not_ possible to control it only with crontab ...
    (Tru64-UNIX-Managers)
  • Re: Cron job question
    ... > From: root@somedomain.nl (Cron Daemon) ... You've made the classic mistake of confusing the system crontab ... extra column defining which user ID the command should be run as. ... any new cron jobs for any user (including root) and leave the system ...
    (freebsd-questions)
  • Re: [opensuse] Re: cron problems
    ... The exception is when your crontab line starts ... your ipdetect cron job really works, you might want to turn off job start ... Your crontab syntax itself is OK, ... userid in it, before the command, has just the command. ...
    (SuSE)
  • Re: Periodic maintenance task will not send mail
    ... cron has it's own environment; if you want to use yours ... you have to read it in specifically, or set it in your crontab. ... the periodic tasks are not running under cron ...
    (comp.sys.mac.system)