Re: Date scripting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Norman wrote:

Hi people,
I need to check files to see how old they are.

How can I do this from within a backup script?

I need to see if they are over a month old, and if so delete them. How do I get they're last modified stamp please?

Cheers,

Chris Norman
<!-- chris.norman4@xxxxxxxxxxxx -->

Use the find command. It is a very powerful command to use. Check the man pages as it can be used for many things.

When you use the find command to delete old files ALWAYS specify the directory name to search down through. If you use a period "." it uses your current directory and if you happen to be in the root, say goodbye to your box. Very dangerous. Also be aware that it will also delete any hidden or system files that it has permissions to.

What I always do is use the find command with echo first. That way I will see exactly which files it will delete.

find /home/jim -name "*" -mtime +30 -exec echo {} \; <- This just displays the filenames

find /backup -name "*" -mtime +30 -exec ls -l {} \; <- This will show you the listing so you can verify the dates

Double and triple check before putting your script into production.

Jim

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux