1. scp同步文件脚本 //syntest.sh#!/bin/bash# Setting cdm path is used to store client software
host_dir="/var/hostdir"
# Statement the file is used to store the size of cdm folder size
fsrecord=".r"
# To synchronize the target machine ip
client_ip="192.168.0.2"
# To synchronize the target machine directory
client_dir="/var/clientdir"# Current file folder size
new_folder_size="$(du -sh $host_dir |awk "{print $1}")"
# Read the size of the folder and remove character "M"
if [ ! -f $fsrecord ]
then
echo "0M" > $fsrecord
fi
old_folder_size="$(cat $fsrecord|tr -d "M")"
# Remove character "M"
temp_new="$(echo $new_folder_size|tr -d "M")"# Compare file folder size
if [ "$temp_new" != "$old_folder_size" ]
then
scp -r $host_dir $client_ip:$client_dir
echo ""
echo "-----The folder has been synchronized success!-----"
# Write the latest file folder size
echo $new_folder_size > $fsrecord
else
echo "-----The folder has not been changed, so it does not need to synchronize.-----"
fi2. 为scp自动拷贝生成不用输入密码的密匙 参考《ssh(scp)自动登录的几种方法》 3. 用crontab定时运行脚本。 1.) 将syntest.sh拷贝到/etc目录下 2.) 编辑crontab,文件在/var/spool/cron/crontabs下 比如:每分钟运行一次 0-59 * * * * /etc/syntest.sh //*/5 每5分钟1次 */20 每20分钟1次 在Linux下可以,但是在Solaris下不支持4. refresh crontab svcadm refresh cronUbuntu 10.10&11.04安装Java+Eclipse及其配置ssh(scp)自动登录的几种方法相关资讯 Solaris
- VMware虚拟机安装x86架构的Solaris (今 14:25)
- Oracle Solaris本地安全漏洞(CVE- (07/17/2015 08:32:02)
- Oracle Solaris 远程安全漏洞(CVE- (10/17/2014 17:12:43)
| - Oracle Sun Solaris 本地安全漏洞( (04月22日)
- Solaris系统配置IPMP教程(基于IP (12/04/2014 13:40:32)
- Oracle Solaris 11.2 正式发布下载 (08/06/2014 12:03:33)
|
本文评论 查看全部评论 (0)