Crontab requires escaping any % signs

Crontab requires escaping any % signs, so this will not work: 0 0 * * * root /root/script.sh "%DATE%"0 0 * * * root /root/script.sh "%DATE%" After escaping any % signs, it will work just fine: 0 0 * * * root /root/script.sh "\%DATE\%"0 0 * * * root /root/script.sh "\%DATE\%"

Bash Check folder size Linux

With du you can check the folder size in human readable format: du -h /path/to/directorydu -h /path/to/directory *** It includes the size of the folder and subfolders *** If you want a simpler output, use this: du -hcs /path/to/directorydu -hcs /path/to/directory

Bash remove the first line of a large file

On Linux OS, using tail you can quickly remove the first line of a file: tail -n +2 file > file.newtail -n +2 file > file.new Alternatively you can use ed (that is still fast): ed <<< $’1d\nwq’ fileed <<< $’1d\nwq’ file You can use also sed, but it is much slower: sed -i 1d […]

ERROR 1114 (HY000): The table ‘site’ is fullage done

If you get this MySQL error while you alter a table: ERROR 1114 (HY000): The table ‘site’ is fullage doneERROR 1114 (HY000): The table ‘site’ is fullage done Make sure the partition is not full. Type this command to see the partition status: df -hdf -h

Get Linux Server Unique Machine ID

Type this command to get the unique machine ID of your server: cat /etc/machine-idcat /etc/machine-id Here are more info about /etc/machine-id: The /etc/machine-id file contains the unique machine ID of the local system that is set during installation. The machine ID is a single newline-terminated, hexadecimal, 32-character, lowercase ID. When decoded from hexadecimal, this corresponds […]

Linux make files accessible only by root

Make files accessible only by root (without +x): chmod 0600 file.logchmod 0600 file.log Make files accessible only by root (with +x): chmod 0700 file.shchmod 0700 file.sh Make all *.sh files accessible only by root (with +x): chmod 0700 *.shchmod 0700 *.sh Make all *.sh files accessible only by root (with +x) recursively: chmod -R 0700 […]

Bash Autologin with MySQL MariaDB server

With MariaDB there is a file that contains user\pass for MySQL autologin: /etc/mysql/debian.cnf/etc/mysql/debian.cnf Here is an example output of /etc/mysql/debian.cnf: # Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = randomstring socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = randomstring socket = /var/run/mysqld/mysqld.sock […]

Bash Check if an array contains a value or an element

This is a Bash function used to check if an array contains a value: arrayContainsValue () { local e for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 1; done return 0 }arrayContainsValue () { local e for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 1; done return […]

Nginx Load Balancing Example

Nginx can be used as load balancer, so it can split the traffic within N servers specified in the upstream section of the Nginx configuration file. This is useful to scale the web traffic if it becomes too much for a single server or VPS. Using Nginx as load balancer is incredibly easy, in short, […]

Firefox Addon to Capture a Screenshot of the Webpage

Do you need to capture the whole webpage or just a portion of it with Mozilla Firefox? Here is a super fast, easy to use and awesome free addon for Firefox that can capture a screenshot of the whole webpage, and save the screenshot image in your desktop by default: Easy Screenshot Easy Screenshot is […]