Every two minutes every day, you'll need a cron entry like:
00,02,04,06,08.......,58 * * * 0-6 /<your script>
to edit the crontab, use crontab -e (an alternative is to edit a separate file then save it and issue a crontab <filename> so that the new file becomes the new crontab). You should be presented with a vi environment (if not do an export EDITOR-vi before editing the file) in which you can enter the baove commands. Then save with a wq! to activate it. Be aware that cron inherits no environment variables, so it may be necessary to add these explicitly if required. For information, I find it easier to add:
#Crontab field order:
#minute (0-59),
#| hour (0-23),
#| | day of the month (1-31),
#| | | month of the year (1-12),
#| | | | day of the week (0-6 with 0=Sunday).
#| | | | | commands
at the top of the crontab so that there is no chance of my getting the various options muddled. HTH.
Dickiebird, must be a Linux thing, first time I have encountered it too, never seen it on AIX. I will try tomorrow on AIX 5.1, maybe I'm lucky.... :-} IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
That's right it doesn't seems to work on both Aix 5.1 & Solaris 8 ... But rmoorthy didn't mention on which *nix he works, Mister Judge. I promise I won't connect back to tek-tips until the end of the week ...
FYI rmoorthy;
you can manually create your own cron file following crontab format (as stated by all of our fine forum members above) and save it to the crontab dir (/var/spool/cron/crontab) . That will be read and executed by the cron utility just like any other one.
This is a good practice to keep the system's crontab content at a minimum and reduce the chances of errors that could prevent other cron-jobs from executing.
For example my backup and other cron jobs used to fail due to I edited the crontab wrongly by inserting too many * on a one-liner that calls other utility script.
But when I inserted a cron-file with the one-liner into the crontab dir, a failure in that file does not affect any other cron-job.
^^^^^^^^^^^^^^^^^^^^^^^^^^
Experience is the Best Teacher
But its' cost is Heavy!
^^^^^^^^^^^^^^^^^^^^^^^^^^
alternatively you can let your program decide to run or not.
so you once edit crontab.
* * * * * /your/path/exec
put in /your/path/exec
#!/bin/sh
case '/bin/date +%M' in *[13579]) exit 0;; esac
....do the job...
exit 0 -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
Nawardez - this */2 bit makes for a heck of an improvement, wish IBM would incorporate it, it will make cron entries so much tidier.
Thanks for the info, you are welcome back here anytime. IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.