You need to have a script that deletes all files in a directory older than 7 days well Linux makes this easy:
Assume the directory we want to use is /local/backup
find /local/backup -mtime +7 -type f -exec rm -f {} \;
and your done.
Random thoughts and technical bits
You need to have a script that deletes all files in a directory older than 7 days well Linux makes this easy:
Assume the directory we want to use is /local/backup
find /local/backup -mtime +7 -type f -exec rm -f {} \;
and your done.
So you have a directory and you want to change permissions on all files in the directory or directories but not the directories themselve it’s easy in linux
Assume the directory I want to start on is /local and I want everything under this directory to be chmod 644 then I would run
find /local -type f -exec chmod 644 {} \;
Or if I wanted to print out results first to check them
find /local -type f -print
Or if I wanted to change the owner to bob:bob
find /local -type f -exec chown bob:bob {} \;
How about you want to change directories only to 755?
find /local -type d -exec chmod 755 {} \;
Have you ever wanted to know if a specific ip address is hitting your web server too much?
It’s simple assuming your logs are in /var/log/httpd (redhat) do the following
cat access_log | awk ‘{print $1}’ | sort | uniq -c
It will output a list like this:
4 127.0.0.1
97 192.168.10.30
100 192.168.10.48
288 192.168.10.49
1 192.168.10.51
19 192.168.10.52
199 192.168.10.53
So you want to know how many different ip’s have been hitting your apache server?
It’s simple to do first locate your logs normally in /var/log/httpd/access_log (redhat)
Look at the log and identify which field is the ip address in ours it’s the first entry so we will use $1 (if it’s the second replace with $2)
cat /var/log/httpd/access_log | awk ‘{print $1}’ | sort | uniq | wc -l
This will output a count of unique hits. You can also get a list with:
cat /var/log/httpd/access_log | awk ‘{print $1}’ | sort | uniq