Running a backup script on a server system as a webhosting server can produce high load and longer latencys for other processes  or php pages load slow during backup because the backup script takes too much  CPU resources.

On Linux systems there are many utilities available for the programming to set the CPU for a appliaction or a script.

In this tutorial we will use nice.

To reduce the CPU priority, use the following command:

/usr/bin/nice -n 19 /location/of/your/script/

The -n parameter can be in the range from -20 to 19.  Lower numbers means higher priority.


Bash: Check if you are root

Valic —  October 20, 2011 — 1 Comment

Using the following you can check if you are root or not when you run bash scripts.

Exmaple 1:

if [ $(whoami) != 'root' ]; then
echo "Must be root to run $0"
exit 1;

Example 2:

ROOT_UID=0 # Only users with $UID 0 have root privileges.
E_NOTROOT=87 # Non-root exit error.

if [ "$UID" -ne "$ROOT_UID" ]
echo "Must be root to run this script!"
echo "You are root!"

You can also use this in your bash scripts.

Watch is a very useful command to run another command periodically.
This is useful for monitoring queries that are causing your server to block.
- n 1 – is the number of secconds between queries.

watch -n 1 mysqladmin --user=root --password=yourpassword processlist

New category

Valic —  October 9, 2011 — Leave a comment

All posts in this category will be useful snippets of different categories such as: bash, linux, mysql, apache, htaccess, and why wordpress and more.

Page 4 of 41234