ssh远程执行命令并自动退出
nohup /usr/bin/python3 -u /usr/local/software/ELK/PutDataToKafkaAll.py >all.log 2>&1 &
sshpass -p 'DsideaL4r5t6y7u!@#' ssh -p 26611 root@10.129.51.80 "ls -la"
sshpass -p 'DsideaL4r5t6y7u!@#' ssh -p 26611 root@10.129.51.80
# 存在文件
[root@AY130805143906Z data]# ls -la /usr/local/db/mysql/data/mysql-bin.002012
-rw-rw---- 1 mysql mysql 718216663 Jun 22 20:43 /usr/local/db/mysql/data/mysql-bin.002012
# 不存在文件
[root@AY130805143906Z data]# ls -la /usr/local/db/mysql/data/mysql-bin.0020123
ls: cannot access /usr/local/db/mysql/data/mysql-bin.0020123: No such file or directory
# 截取canal binlog日志文件
[root@AY130805143906Z example]# cat /usr/local/canal/logs/example/meta.log | tail -1 | awk '{print $5}' | cut -d ',' -f 1 |cut -d '[' -f 2
返回 :mysql-bin.002012
# ssh版本
sshpass -p 'DsideaL4r5t6y7u!@#' ssh -p 26611 root@10.129.51.80 "cat /usr/local/canal/logs/example/meta.log | tail -1 | awk '{print $5}' | cut -d ',' -f 1 |cut -d '[' -f 2"