Rsync via PHP exec() with SSH passwordless ssh login

前端 未结 5 916
刺人心
刺人心 2020-12-30 08:30

If I run the command via php exec(): It does not work. But if I use bash, it runs perfect. Any idea what the problem might be.? I was thinking maybe it is executing rsync as

5条回答
  •  庸人自扰
    2020-12-30 09:14

    store the command in a shell script, since it has no dynamic parts, and then use exec() to execute the shell script.

    # on command line    
    echo 'rsync -au /var/www/html/f1/ user@000.000.000.000:/var/www/html/f2/' > sync_files
    
    # On command line
    chmod +x sync_files
    
    
    

提交回复
热议问题