Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Every hour, the file /home/xml/xml.xml should be replaced by one of the 24 xmlfiles, but still be named only xml.xml. Every hour, xml.xml should be replaced by the next xmlfile in line.
So this should probably be done by using a cronscript and a shell script. The server is redhat 9.0.
This'll be homework will it? And don't offer money to our members please, LQ is a community and we do this all for no fee - let's try to avoid setting a precedent.
Grab a book on Shell programming and you will probably find this sort of thing as an example. Or look for the equivalent on-line.
I can outline the solution but I can't provide one... however, if you look around your system (say in the "/rc.d/init.d" scripts or any existing cron jobs) you might find one.
If you execute the "date" command programmatically, using the backslash {`} mechanism of the shell, you'll get a string. One particular substring is going to be the digits that you want. Extract that piece, build the file-name. Use a "cp" command to copy the file. The destination filename is always the same.
Put that in a script (/etc/cron.hourly/move_xml.sh), and change the pemissions ($ chmod 700 /etc/cron.hourly/move_xml.sh) and run the script once an hour ... I.E.
$ crontab -e
Add the following line
0 * * * * /etc/cron.hourly/move_xml.sh
executes on the hour every hour, every day, 24/7.
The back ticks kind of shoot the enclosed part off into its own little shell, then returns the results. The first cut statement grabs the time on the system, and the second pulls only the hour. The sed is needed because single digit hours are prefaced with a 0, but your files don't preface those numbers, so the leading 0 has to be stripped.
Put that in a script (/etc/cron.hourly/move_xml.sh), and change the pemissions ($ chmod 700 /etc/cron.hourly/move_xml.sh) and run the script once an hour ... I.E.
$ crontab -e
Add the following line
0 * * * * /etc/cron.hourly/move_xml.sh
executes on the hour every hour, every day, 24/7.
The back ticks kind of shoot the enclosed part off into its own little shell, then returns the results. The first cut statement grabs the time on the system, and the second pulls only the hour. The sed is needed because single digit hours are prefaced with a 0, but your files don't preface those numbers, so the leading 0 has to be stripped.
The thanks are all that I need. I helped because I enjoy figuring out things like this, and I really like to help out where I can. That is also why I explained what everything was doing so that Freddiee and others that stop by the thread can learn and understand it.
I don't have a PayPal account. Money was never the goal, only to help.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.