Tuesday, July 26, 2011

Delete Files Older Than x Days on Linux

find /backup/* -mtime +5 -exec rm {} \;

How To create a MySQL database and set privileges to a user

mysql> CREATE USER 'root'@'10.0.0.1' IDENTIFIED BY 'password';


mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.0.1' WITH GRANT OPTION;


mysql> FLUSH PRIVILEGES;

Thursday, July 21, 2011

Linux – Kill a Process by Name

If you know the command

ps -A

then tou will probable also know

ps -A | grep firefox

now you can manually kill this via

kill -9

Where is from the last output. But how to do this in one line? If your ps command knows:

ps opid= -C firefox
(should print the )

Then you can simply do

kill -9 $(ps opid= -C firefox)