Category: Linux 分享

Dialy Backup Task

1 Comment on Dialy Backup Task

February 14, 2008 at 11:22 pmCategory:Linux 分享

I would like to share some experience on daily backup task even though I'm not a Linux expert.

Noticed below user group created.
someonex:500:
apache:x:48:
mysql:x:27:
webmaster:x:501:
fred:x:502:

Suggest to create a backup group with a dedicated user for backing up db & web src.
 
A sample db backup script is available at /home/fred/backup_db.sh
The last command (I coded all tables) in script is commended out for Fred to inform all of us which table should be backup.
=============================================
aDate=`date +%Y%m%d`
filename="bkup""$aDate"
echo "Creating daily backup <"$aDate"/"$filename">"
#mysqldump –add-drop-table –allow-keywords -q -a -c -u username -ppassword –all-databases > $filename.sql =============================================

A sample cron job is setup to run the backup scripts. (Please note that the cron job is exec under the user home, so the cron jobs has to be set under the new user instead of Fred/root)
e.g. every day 18:30
=============================================
[fred@panda ~]$ crontab -l
30     18     *     *     *         ./backup_db.sh > backup.log
=============================================

Belows stated fyr to edit the cron job. 
crontab -e     Edit your crontab file, or create one if it doesn't already exist.
crontab -l      Display your crontab file.
crontab -r      Remove your crontab file.
crontab -v      Display the last time you edited your crontab file. (This option is only available on a few systems.)

If www scripts are expected to create daily backup, similar scripts should be setup.
** The scripts should be coded in a better manner to spool a log instead of redirecting from cron job 😀

Common Linux Command

No Comments on Common Linux Command

February 14, 2008 at 11:03 pmCategory:Linux 分享

Common Linux command for server administration.

1. top
performance monitor, CPU, memory usage, paging…etc

2. ps -ef
list out all process which is running

3. grep
a find unitility
mix with ps, list out the processes launched by this user
e.g. ps -ef | grep [user name]

4. kill
purge process
e.g. if httpd is hang up and normal shutdown of web server / db failed,
with 2 & 3, obtain the process ID
then kill the process manually.
e.g.
[root@mylinux root]# ps -ef | grep nobody
root     18970 18264  0 09:24 pts/0    00:00:00 grep nobody
[root@mylinux root]# kill -9 18970
Remark: -9 means force kill

5. vnc
Linux build in vnc server support, in console, use
$vncserver [session id]
to start a session
e.g. vncserver :1
after using, type $vncserver -kill [session id] to terminate the remote desktop
e.g. vncserver -kill :1