<commit_before>---
layout: post
title:  "Linux常用脚本"
---

记录日常使用到的脚本


# 把本地文件夹备份至远程服务器

1.通过scp

	#!/bin/bash
	dd=`date '+%Y-%m-%d-%H%M%S'`
	scp -i /root/.ssh/id_rsa -P 22 -r /local <EMAIL>:/backup/${dd}

2.通过windows共享 (如果有防火墙，需允许445, 135, 137, 138, 139 UDP和TCP)

	#!/bin/bash
	dd=`date '+%Y-%m-%d-%H%M%S'`
	smbclient -c "mkdir ${dd};prompt OFF;recurse ON;lcd /local;cd ${dd};mput *" //IP/share -U username%password


# 切换到当前目录执行脚本

	#!/bin/bash
	MY_PATH=$(cd "$(dirname "$0")"; pwd)
	cd $MY_PATH


# 防止脚本重复执行(每次只有一个脚本在执行)

	#!/bin/bash
	function run_only_one(){
	        PID=$$
	        snum=`ps -ef|grep $0|grep -v grep|grep -v " $PPID "|grep -v " $PID "|wc -l`
	        if [ $snum -lt 1 ]; then
	            echo "start process....."
	        else
	            echo "runing....."
	            exit
	        fi  <commit_msg>'update'<commit_after>---
layout: post
title:  "Linux常用脚本"
---

记录日常使用到的脚本


# 把本地文件夹备份至远程服务器

1.通过scp拷贝目录

	#!/bin/bash
	dd=`date '+%Y-%m-%d-%H%M%S'`
	scp -i /root/.ssh/id_rsa -P 22 -r /local <EMAIL>@mal<EMAIL>:/backup/${dd}

2.通过windows共享 (如果有防火墙，需允许445, 135, 137, 138, 139 UDP和TCP)

	#!/bin/bash
	dd=`date '+%Y-%m-%d-%H%M%S'`
	smbclient -c "mkdir ${dd};prompt OFF;recurse ON;lcd /local;cd ${dd};mput *" //IP/share -U username%password


# 切换到当前目录执行脚本

	#!/bin/bash
	MY_PATH=$(cd "$(dirname "$0")"; pwd)
	cd $MY_PATH


# 防止脚本重复执行(每次只有一个脚本在执行)

	#!/bin/bash
	function run_only_one(){
	        PID=$$
	        snum=`ps -ef|grep $0|grep -v grep|grep -v " $PPID "|grep -v " $PID "|wc -l`
	        if [ $snum -lt 1 ]; then
	            echo "start process....."
	        else
	            echo "runing....."
	            exit
	        fi  
{'fraction_non_alphanumeric': 0.20637785800240674, 'fraction_numerical': 0.026474127557160047, 'mean_word_length': 2.3061630218687874, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '351829', 'n_tokens_mistral': 911, 'n_tokens_neox': 858, 'n_words': 156}