顯示具有 linux 標籤的文章。 顯示所有文章
顯示具有 linux 標籤的文章。 顯示所有文章

2014年11月4日 星期二

linux-script parameter

parameter

root@cloud-adm:/backup# cat backupDay

#!/bin/bash
# Incremental Backup
#d=`date +%y%m%d%H%M%S`
d=`date +%a`
s=$1
lftp -c "open -u userID,password 1.1.1.999/userID; rm -r /userID/$s/$d"
mysqldump -ususer -pez=DatabaseName $2 > /backup/$2.sql
mysqldump -ususer -pez=DatabaseName erp > /backup/erp.sql
tar -jvcf /backup/$2.tar /backup/$2.sql
ncftpput -m -u userID -p password 1.1.1.999 /userID/$s/$d/db_dump /backup/*.*
ncftpput -R -m -u userID -p password 1.1.1.999 /userID/$s/$d/attachment /erp/$2
#ncftpput -R -m -u userID -p password 1.1.1.999 /userID/$s/$d/attachment /erp/$2
ncftpput -m -u userID -p password 1.1.1.999 /userID/$s/$d/code/layout /erp/*.*
ncftpput -m -u userID -p password 1.1.1.999 /userID/$s/$d/code/css /erp/css/*.*
ncftpput -m -u userID -p password 1.1.1.999 /userID/$s/$d/code/js /erp/js/*.*
ncftpput -m -u userID -p password 1.1.1.999 /userID/$s/$d/code/images /erp/images/*.*
ncftpput -m -u userID -p password 1.1.1.999 /userID/$s/$d/code/fonts /erp/fonts/*.*
ncftpput -R -m -u userID -p password 1.1.1.999  /userID/$s/$d/code/java /erp/WEB-INF
rm $2.sql

backupDay CompanyName DatabaseID

2014年9月18日 星期四

linux-cp


copy multi file to multi file

for file in source* ; do cp "$file" "${file/source/Target}";done

for file in salesSubject* ; do cp "$file" "${file/salesSubject/purchaseSubject}";done


for file in purchaseApply* ; do cp "$file" "${file/purchaseApply/officePurchaseApply}";done

for file in purchaseRequest* ; do cp "$file" "${file/purchaseRequest/officePurchaseRequest}";done


for file in collectionNote* ; do cp "$file" "${file/collectionNote/specialRequestDNote}";done


for file in salesman* ; do cp "$file" "${file/salesman/pjInCharge}";done

for file in paymentTerms* ; do cp "$file" "${file/paymentTerms/paymentTermsFormula}";done


for file in dNotes* ; do cp "$file" "${file/dNotes/returnNote}";done

for file in customerCategory* ; do cp "$file" "${file/customerCategory/supplierCategory}";done

for file in productMaster* ; do cp "$file" "${file/productMaster/internalItem}";done

for file in salesType* ; do cp "$file" "${file/salesType/internalType}";done

for file in purchaseRequest* ; do cp "$file" "${file/purchaseRequest/stockIssue}";done

for file in BOM* ; do cp "$file" "${file/BOM/salesOrderPayment}";done

for file in uom* ; do cp "$file" "${file/uom/dept}";done


for file in BOM* ; do cp "$file" "${file/BOM/purchaseRequest}";done

for file in solutionType* ; do cp "$file" "${file/solutionType/quotationStatus}";done

for file in inBox* ; do cp "$file" "${file/inBox/quotation}";done

for file in category* ; do cp "$file" "${file/category/solutionType}";done

for file in salesType* ; do cp "$file" "${file/salesType/pjTeam}";done

for file in productCategory* ; do cp "$file" "${file/productCategory/TARGET_FILE_NAME}";done

for file in productCategory* ; do cp "$file" "${file/productCategory/maintainType}";done

for file in category* ; do cp "$file" "${file/category/pvia}";done

2014年9月16日 星期二

linux dynamic mkdir folder

#!/bin/bash
# Incremental Backup
d=`date +%y%m%d%H%M%S`
file=" /backup/entities/incremental_backup/$d":
mkdir $file
DIST=/source/entitles/folder/data/
DIST_OLD=/FullBackup/Entities/Folder/Data/
DIST_UPGRADE=$file
cd $DIST
list=`find . -type f`
for a in $list; do
if [ ! -f "$DIST_OLD$a" ]; then
cp -vpf --parents $a $DIST_UPGRADE
continuevi
fi
diff -a $a $DIST_OLD$a > /dev/null
if [[ "$?" == "1" ]]; then
echo copying
# File exists but is different so copy changed file
cp -vpf --parents $a $DIST_UPGRADE
fi
done

2014年9月14日 星期日

Linux Cron

linux-cron

Linux Scheduled Jobs is scheduler system know as Cron that allows system administrators to automate rescurring administrative tasks or users to automate their routine works.



There are 2 types of Scheduled Jobs:

1. User Scheduled Jobs - Which is set by a non-root user and runs under a non-root user's privilege.
2. System Scheduled Jobs - Which is set by root and runs under Super User's Privilege.

The scheduler system includes the following components.
1. The Cron Daemon - crond(8)
2. The Configuration file - /etc/crontab (5) and /var/spool/cron/*
3. The Command - crontab(1)

The Cron Daemon - crond(8)

The Cron Daemon is the primary server service for all types of scheduled jobs. For every minute, it reads all configuration files including system scheduled jobs from 'etc/crontab' and all users scheduled jobs from 'var/spool/cron/*. If it finds jobs that needs to be run at that time, it will run them.

Since the above operations is performed every minute, therefore the unit of time in the configuration is in minute. In other words, you can schedule a job to run every minute but not every second.

The Configuration files

The configuration file 'etc/contab' is used for storing system scheduled jobs and can be edited directly by SuperUser only.

The configuration file under the directory '/var/spool/cron' are used for storing users' scheduled jobs.
For example :
The scheduled jobs for the user peter are stored in the file /var/spool/cron/peter.
The scheduled jobs for the user ada are stored in the file /var/spool/cron/ada.

However, users can only edit them through the command 'crontab' and they only edit their own file.

The Crontab files
Min Hour Day Month Weekday RunAs (/etc/crontab only)  Command(Action)
* * * * * root command i.e. every minute
0 * * * * root command i.e. every hour
0 12,13 * * * root command i.e. 12:00 13:00
15 2 1 * * root command i.e. 1st  day of every month at 2:15
15 4 */3 * * root command i.e. every 3 days at 4:15

Scheduling User CronJobs

For users to maintenance their scheduled jobs, they need to use the 'crontab' command. There a few options available in the 'crontab' command:

crontab -e to edit user's own cronjob  // crontab -u peter -e  <-- Root
crontab -l to list the usr's own cronjob // crontab -u peter -l <-- Root
crontab -r to remove the usr's own cronjob // crontab -u peter -r  <-- Root

e.g. peter edit his own job

crontab -e
* * * * * date >> /home/peter/datafile
ESC :wq

The cron job file for Peter is created but Peter cannot view it directory.
Normal users has no right in accessing the directory '/var/spool/cron' and can only access it through 'crontab' command what has SetUID bit configured.

To view his own cronjob:  crontab -l

ps -fC cron(d)
chkconfig --list cron(d)
chkconfig corn(d) status
chkconfig --level 2345 cron(d) on
service cron(d) restart

Scheduling System Cronjobs

vi /etc/contab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * * root run-parts /etc/cron.weekly
41 1 1 * * root run-parts /etc/cron.monthly

Actual 'run-parts' is a script that reads and run the script file in the specified directory (i.e. '/etc/cron.daily').

Note that all entries use different values in the minute column. If not, jobs from diffrent directories will be started at the same time. These will seriously affect the performance of the Linux machine durring that period.


In order to configure system cron jobs, you can

Create an entry directly in the /etc/crontab file e.g.

* * * * * root date>> /root/datefile
 or

Prepare a script file and then put it into the appropriate directory. e.g. for a script file that needs to be run monthly, put it into the directory '/etc/cron.monthly'.


































2013年12月3日 星期二

linux-grep




 grep PURCHASE_HEADER_BAK * | grep TIMESTAMP

-
grep 2 constrain
grep jdbc:mysql *.java | grep hr  > abcd.txt

-

2013年11月27日 星期三

install cvsd server


inf : http://mazanatti.info/archives/67/


Step 1
shell #vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 4.4.4.4
~
`
shell # apt-get install cvsd







 ┌──────────────────────────────────────────────────────┤ Configuring cvsd ├ │ The whole idea of cvsd is to serve repositories. Specify a colon ':' separated list of repositories to serve. The location of  │ │ these repositories is relative to the specified chroot jail (/var/lib/cvsd) and should start with a '/'.                       │ │                                                                                                                                │ │ The repositories here should be initialized by hand with something like 'cvs -d /var/lib/cvsd/myrepos init' after which        │ │ passwords can be set with 'cvsd-passwd /var/lib/cvsd/myrepos anonymous'. See the file /usr/share/doc/cvsd/README.gz for        │ │ details on creating repositories.                                                                                              │ │                                                                                                                                │ │ Repositories to serve:                                                                                                         │ │                                                                                                                                │ │ /demo:/myrepos________________________________________________________________________________________________________________ │ │                                                                                                                                │ │                                     <Ok>                                         <Cancel>                                      │ │                                                                                                                                │ └──────────────────────────────────────────────────────────────────




Quick guide: installing CVS Server on Ubuntu 11.04



  • 1. Install required packages

    sudo apt-get install cvsd

  • 2. Adjust daemon parameters


    Open the configuration file:
    sudo vi /etc/cvsd/cvsd.conf
    Most likely, you gonna need to change these lines:
    # This is to avoid the "address already in use" error when starting cvsd:
    Listen 0.0.0.0 2401
     
    # You may want to change the root folder where your repositories will be created:
    RootJail /var/lib/cvsd
     
    # Go to the end of the file, and enter lines like these, one for each repository you need:
    Repos /project1
    ...
    Save the file and exit the editor.


  • 3. Create and initialize repositories

    sudo mkdir /var/lib/cvsd/project1
    sudo cvs -d /var/lib/cvsd/project1 init

  • 4. Change root folder owner to cvsd

    sudo chown cvsd:cvsd /var/lib/cvsd -R

  • 5. Create repository users

    sudo cvsd-passwd /var/lib/cvsd/project1/ john
    sudo cvsd-passwd /var/lib/cvsd/project1/ mary

  • 6. Fire up (or restart) the daemon

    sudo /etc/init.d/cvsd restart
    Check for errors at /var/log/syslog (you can change this setting at cvsd.conf). If something is wrong, check the message and correct it - probably, something related to network or file permission...


  • 7. Create a reference to the repository and use it!


    Open a terminal, and enter the following commands:
    export CVSROOT=:pserver:fabio@localhost:2401/project1
     
    cvs login
    ...
    cvs logout
    I like to use these commands to test the environment, but you can go ahead and configure your preferred CVS GUI client.


  • Cheers!