I am a constant user of screen and it always suprises me how many people use it and barely know how truly powerful it is. Here is a short list of some very neat tricks.
| Starting a new session |
screen |
| Reattach to a session |
screen -r |
| Leave a session |
^A d |
| Open another window |
^A c |
| Change to a window |
^A number |
| Change to next window |
^A space |
| Change window via the window list |
^A “ |
| Add a split region |
^A S |
| Jump between split regions |
^A tab |
| Close region |
^A X |
| Close all the other regions |
^A Q |
| Enter “copy mode” (useful for scrollback!) |
^A [ |
| Watch for silence |
^A _ |
| Watch for activity |
^A M |
| Protect screen with password |
^A x |
As always looking through info and man pages can provide a raft of information about tools and sometimes uncover tricks that you might of otherwise not known about!
This is a really simple script that can be used to backup all the databases in a MySQL server. Thought I’d put it here as it shows some basic scripting techniques that maybe will help people see how to write scripts. Basically all this does is save me from having to type out the date. It could be automated but that would require storing the user name and password somewhere which normally isn’t too smart an idea.
#!/bin/sh
# GNU GPL version 3.0 or above
# Copyright (c) 2009 Mark Sangster
if [ -z "$3" ]; then
echo 'mybackup <user> <password> <host>' >&2
exit 1
fi
MYUSER=$1; MYPASS=$2; MYHOST=$3
mysqldump -u $MYUSER -p $MYPASS -h $MYHOST -A | \
bzip2 -9 > mysql-`date +%Y-%m-%d`.bz2
The script usage is very striaght-forward:
# mybackup user pass host
At which point you will find a file called “mysql-2009-01-27.bz2″ or similar. Nothing to difficult!
A problem that seems to crop us with these now and then is that one of the recorded files in your Library becomes corrupt and seemingly impossible to delete. When you select it the box freezes and requires to be hard restarted by removing the power. There is however a solution.
- Select “Menu”
- Option 4 – “Setup”
- Option 6 – “Help”
- Type in 1397 (this is to enter the “Engineer” panel)
- Option 7 – “Disable Library Video Window”
- Go back to your library now and select then delete the offending file.
That’s it, the reason that it is freezing is that the small preview window is attempting to load the corrupted file thus freezing the box. Disabling that preview window allows you to delete the file without it loading.
Once complete, the preview window will automatically enable itself again.
Comments