Bash Snippets
A few useful (or pointless) Bash snippets that come in handy every now and then. Have fun with them.
Create a complete MySQL dump
mysqldump -u root -p -A -R -E --triggers --single-transaction > full_backup.sql
Detach a process from the terminal
nohup sh -c '$1' &
Find the PID of a process
ps -ax | grep $1 | grep -v ' grep '
Shutdown timer
sudo shutdown -h +$1
Limit CPU
Sometimes you don't want to give a process the highest priority. That's where "nice" and "renice" come in handy. With "nice" we start a new process ($command) with a chosen priority ($niceness).
nice -n $niceness $command
With "renice" we set the priority of a process that is already running.
renice $niceness $options
Possible options are:
-p PID: select the process by its process ID-u USER: limit the processes of the user USER-g GROUPID: select all processes with the process group ID GROUPID