- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- i need run one command >> file(CRON) on every 1st...
Operating System - Linux
1753265
Members
5619
Online
108792
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2008 11:34 PM
тАО05-06-2008 11:34 PM
HI,
i need run one command >> file on every 1st monday of every month.
pls help me to write script to verify its 1st monday and then to the crontab entry!!
Please advice if any solution.
i need run one command >> file on every 1st monday of every month.
pls help me to write script to verify its 1st monday and then to the crontab entry!!
Please advice if any solution.
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 12:51 AM
тАО05-07-2008 12:51 AM
Solution
maybe it help├В┬┤s ....
Specific day in a given week
Another common request is to run a command only on a particular day in a particular day of the month. For example, you might want to run a report on the first Monday of each month, or the last Friday. To achieve this, you can use a similar process to the one above. For any particular day in a given week, it must fall within one of the following dates:
Week 1: 1st to the 7th
Week 2: 8th to the 14th
Week 3: 15th to the 21st
Week 4: 22nd to the 28th
To determine whether the current date is within a given range, for example, the fourth week, you would use a test like this:
[ `date +\%e` -gt 21 -a `date +\%e` -lt 29 ]
The %e is used to return a number for the day, where numbers less than 10 are prefixed with a space, rather than a zero, which ensures that numbers, not strings, are compared.
You can now combine this with a crontab definition that attempts to run the command every Friday:
59 23 * * 5 [ `date +\%e` -gt 21 -a `date +\%e` -lt 29 ]
&& do-something
The command will be run every Friday, but because the test will only return true in the fourth week of the month, the real command will be executed on the fourth Friday.
Specific day in a given week
Another common request is to run a command only on a particular day in a particular day of the month. For example, you might want to run a report on the first Monday of each month, or the last Friday. To achieve this, you can use a similar process to the one above. For any particular day in a given week, it must fall within one of the following dates:
Week 1: 1st to the 7th
Week 2: 8th to the 14th
Week 3: 15th to the 21st
Week 4: 22nd to the 28th
To determine whether the current date is within a given range, for example, the fourth week, you would use a test like this:
[ `date +\%e` -gt 21 -a `date +\%e` -lt 29 ]
The %e is used to return a number for the day, where numbers less than 10 are prefixed with a space, rather than a zero, which ensures that numbers, not strings, are compared.
You can now combine this with a crontab definition that attempts to run the command every Friday:
59 23 * * 5 [ `date +\%e` -gt 21 -a `date +\%e` -lt 29 ]
&& do-something
The command will be run every Friday, but because the test will only return true in the fourth week of the month, the real command will be executed on the fourth Friday.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 12:56 AM
тАО05-07-2008 12:56 AM
Re: i need run one command >> file(CRON) on every 1st monday of every month.
Shalom,
Use an add in tool in the script which runs every Monday but only does real work the first Monday of the month.
http://mirrors.develooper.com/hpux/caljd-2.25.sh
http://mirrors.develooper.com/hpux/caljd-2.2.pl
These toys will let you do fun things with dates. You may need to change the shell in the first one.
SEP
Use an add in tool in the script which runs every Monday but only does real work the first Monday of the month.
http://mirrors.develooper.com/hpux/caljd-2.25.sh
http://mirrors.develooper.com/hpux/caljd-2.2.pl
These toys will let you do fun things with dates. You may need to change the shell in the first one.
SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP