mardi 1 octobre 2019

Check if file exists remotly in bash

I have a bashscript which checks if a file exists on the remote server. When i execute this bashscript on commandline it works fine. But when crontab is executing this script it says that the file not exist. But it exist!

can anybody help me?

myscript.sh

    #!/bin/bash
    if $(sudo ssh <user>@<ip> "[[ -f /etc/ssl/file.txt  ]]");then
       echo "exist"
    else
       echo "not exist"
    fi

crontab:

    */1 * * * * bash /home/user/.acme.sh/myscript.sh | mail -s "betreff" user@email.com

Thanks for helping :D

Aucun commentaire:

Enregistrer un commentaire