Hello:
I have a script that gets the ACLs of the /home directory and its contents with getfacl and writes them to a file. The script is run by a cron job and I don't want it to rewrite or append to an already existing file. The point of backing permissions up is because I may need to restore them. But I don't want to store every single created file either.
The files don't need to have a specific naming convention. In fact, I took advantage of this: I decided to name the files after the date they were created:
This has the advantage that the most recent files are alphabetically greater than older ones, so I thought of putting them in the positional parameters and delete the one I didn't want to preserve. For example, if I wanted to have a maximum of 7 files in the /var/acl_backups directory:
Changing the locale of LC_COLLATE may be unnecessary, but I decided to change it just to be sure it sorts numbers from 0 to 9.
My question is: is this a reliable way to rotate files? I thought of using logrotate was well, but as far as I know, it would mean that every file would have the same name except for a number at the end. If I ever need to restore them with setfacl having the date in their names is very convenient.
Your approach might work; its ramifications aren't fully clear to me. rming $7 does not necessarily target the correct, intended file; with 8 files it will delete yesterday's file as they are set in an increasing order.
Your approach might work; its ramifications aren't fully clear to me. rming $7 does not necessarily target the correct, intended file; with 8 files it will delete yesterday's file as they are set in an increasing order.
Yes, if there were 8 files it would leave the oldest file intact. That's why the script makes the check before backing the ACLs up. In practice the script will use a directory where nothing else will be stored, and the first time the script is run there will be no backups. That's why I know beforehand that there won't be more than 7 files.
Quote:
Originally Posted by RudiC
Why not use find with one of its -newer tests?
-newer and -cnewer compare the modification time, -anewer compares access time. -newerXY can compare the birth time, but not all systems support it. The Linux kernel introduced crtime in version 4.11, and some distros I use have an older release. Namely Debian Jessie.
What's the advantage of using find and the -newer operands rather than having a file naming convention to tell their creation time?
Hi All,
I have a requirement to write a shell script to search the logs in past 1 hour and extract some pattern from it and count it cumulatively to a file.
The problem which I'm facing here is - logs rotates on size basis, say if size of log reaches 5 MB then new log will be generated and... (7 Replies)
Hi all,
We have the exim mail server configured on cpanel in centos. We have 5 dedicated ip's. So, when i sending mails to client systems, it should be rotate that ip addressees on every 15 minutes.
That means Ip rotating. How can i do it. Can anybody show me how to do it.
Thanks, (0 Replies)
I want to take daily backup(11pm) of /var/www to /mnt/bak excluding /var/www/videos and /var/www/old. HOW to implement a rotating snapshot method, so that i can have multiple(say 4) automatically rotating backups. (0 Replies)
Hi there,
I like to ask how i shall monitor specific string or keyword in rotating log files. e.g. I have at 10 rotating logfiles.
I use the command below to grep the string, but eventually become non functional because the logfile rotates and new logfile is active.
tail -f <logfile1> |grep... (1 Reply)
Hi,
I am having some troubles using /usr/sbin/logadm to rotate sulog yearly. Can someone please assist with the correct syntax to rotate the sulog yearly? I'd like to maintain up to 3 years of logs.
I am on Solaris 10.
Thanks, (1 Reply)
(I'm aware log rotation is a common subject, but I tried searching and couldn't find an answer)
For some time now, I've been using the Logfile::Rotate module to rotate logs in a log-monitoring script. So far, I haven't experienced any problems, and it works great because I can use it in Linux... (1 Reply)
I have been using logrotate for quite awhile now. Most logs are rotated daily, using /etc/cron.daily. I noticed that the logs in question have not been rotated since April 6, but daily up to that point.
I have logrotate in /etc/cron.daily. The basic command is:
/usr/sbin/logrotate... (1 Reply)
Hi All,
I have some data (below) that I need to rotate 90 degrees - in other words I want to flip each row into a column.
I've found the following code in the book "Effective awk programming" but it doesn't work on my input data. I've used arrays before but I can't make it work... can... (3 Replies)
Im about to install a sunfreeware program called logrotate which does exactly what it says on the tin....just a quick question ..if its going to rename messages to messages.0 etc do I need to issue a HUP to syslogd after doing this or will the new messages file get created automatically
cheers (2 Replies)
Hi folks,
I want to rotate a string in Clock or Ani Clock wise.
That is
If the string is "TAMIL"
the out put should be
TAMIL
AMILT
MILTA
ILTAM
LTAMI
TAMIL
Please do help. (1 Reply)