Openmips Enigma2 restart cron Gigablue

If you use a Gigablue SAT Box,after some weeks enigma2 will hang up:

edit root crontab:

$crontab -e

insert:
0 1 * * *   killall -9 enigma2 && sleep 5 && init 3 && /etc/init.d/samba restart
5 1 * * *   wget -O /dev/null -q "IP-OF-GIGA-Box/web/powerstate?newstate=0&type=0"

This will restart enigma2 Service, Samba and Webinterface too! Then Enigma is set to Standby!
That kodi can access the TV Bookmarks to view TV over LAN! If Standby is not set Kodi hangs!

Locale Umloud Problems Cron

If you run scripts to handle text output by cronjobs your perhaps get problems with umlouds „ÖÄÜ“ cause they are displayed by „**“.
This is a problem cause cron uses „C“ setting as locale, you can test it by setting it into root crontab:

open crontab from root with:

$su - root
$crontab -

insert
* * * * * locale

This will mail cron’s locale echo to the mailbox of root! Read root’s mail!
After tests remove the locale entry at crontab!

Howto fix for Scripts:

open crontab from root with:

$su - root
$crontab -e

insert (for German):

LANG=de_DE.UTF-8 
LC_ALL=de_DE.UTF-8

for US:
LANG=en_US.UTF-8 
LC_ALL=en_US.UTF-8

MySQL : Backup and Restore Database without phpmyadmin (commandline)

Problem: phpmyadmin interfaces are slow and often attacked by script kids, if you can don’t use it!

Solution: To backup and restore use command line

To Backup a database:

 
$mysqldump -u root -p  wordpressdb > /backups/wordpressdb-dump.sql [Enter root password]

To restore:

$mysql -u root -p wordpressdb < /backups/wordpressdb-dump.sql[Enter root password]

Remark: this is not recogized by the ONLINE SYSTEM if users visits you pages to read! There must be no shutdown of the mysql or apache webserver, its a online HOT-Dump. If you like put it into a script and set cron to backup every night.
Sample Bash MySQL Script for full automatic dumps:
#!/bin/bash
## automatic dump database and add time and date stamp ##
date=`date +%d%m%Y-%H%M`                       # set current date value
mysqldump wordpressdb > /backups/wordpressdb-$date.sql  # save+date
exit  # close script after work

To save all Databases on one MySQL-Server change
mysqldump --all-databases > /backups/server-all-$date.sql

now run
 #crontab -e

set time to run:
@daily   sh /scriptpath/backup-databases.sh > /dev/null 2>&1

This runs daily backup at 00:00AM and post no message to Admin (root) if you need mails remove (>…1)

Debian Ubuntu Update Script with Switch OFF after update

Problem:
I f you work on you PC daily Patches must be checked and installed.
At Debian / Ubuntu the Gnome-Update-Manager does this. But there is
NO Shutdown possible after update.

Solution:
– create Script #sudo nano /root/upgrade-off.sh
add inside:

apt-get update           //for update Patches Database PC
apt-get dist-upgrade -y         //install Patches automatic
apt-get clean      //cleanup PC
/sbin/init 0      //shutdown PC automatic or reboot Server = init 6
exit

You can now after work set it to crontab or start manual by #sudo sh /root/upgrade-off.sh

On Servers name it upgrade-reboot.sh and set root cron to run the job @hourly/@daily