Showing posts with label cli. Show all posts
Showing posts with label cli. Show all posts

Tuesday, February 16, 2010

Find and delete

Someone didn't appreciate the existence of queueing systems like PBS and rolled their own queueing system that is supposed to take care of removing dead jobs from an app server. So I had to look for the old files that were causing the problem and see if I could delete them. Thankfully this is really easy with a simple find command.

 find ./ -type f -mtime +10 

Switching the -type to d will do the same for directories. Unfortunately there is no clever hack for beating people who do this kind of thing over the internet.

Tuesday, January 13, 2009

Disk space usage

My VM keeps getting filled up, and then crashing cos the programs that write logs are not being correctly handled by the underlying FS. So I am interested in generating useful infos on the disk to find out where all the disk space is at. The command du is a big help here. But I frequently just want to know in which directories the most space is being used.

du -h --max-depth=1

That command will give you a listing of which directories under the current dir are using all the space. So in the home dir or at the usr dir run this and find out where all the unneccessary crap is.

Giving me in the /usr dir the following output:
1.1G    ./share
40K ./games
1.4G ./local
7.1M ./sbin
125M ./src
36K ./X11R6
136M ./bin
14M ./include
1.6G ./lib
4.3G .


And this tells me that I ought to tidy up the /usr/local dir. If you ran the above command without the max-depth option then the resulting output will probably overrun your cache/history in your bash shell and besides the output would be impossible to make sense of.

Tuesday, December 9, 2008

SCP fail

I was trying to copy a bunch of pdfs from my desktop to a server using scp. This command failed:

/usr/bin/scp user@example.com:~/foo/bar/*.pdf Training/


It returned a error saying "/usr/bin/scp: No match.". This is because the regex wildcard is expanded on the local machine (in this case the server) where the files are not present and therefore not found.

Whereas this one worked.
/usr/bin/scp user@example.com:~/foo/bar/\*.pdf Training/

Notice that the wildcard is now escaped so that it is ignored on the server but will be expanded when scp gets to the remote machine.