crontab定时任务不执行 expect

1. 路径要写全路径

2. 

#!/usr/bin/expect -f 

set filepaths [lindex $argv 0]
spawn scp -r  root@ip:/usr/local/src/$filepaths  /usr/local/src/mogondb_data_back/

expect {
        "*yes/no"  {send "yes\r"; exp_continue}
        "*password:" {send "password\r"}
}

interact

 

中的interact 换成

#!/usr/bin/expect -f 

set filepaths [lindex $argv 0]
spawn scp -r  root@ip:/usr/local/src/$filepaths  /usr/local/src/mogondb_data_back/

expect {
        "*yes/no"  {send "yes\r"; exp_continue}
        "*password:" {send "password\r"}
}

set timeout 60
expect eof

exit

3.查看crontab 是否启动

你可能感兴趣的:(liunx)