copy files from an ubuntu server to remote server through ssh remote with cronjobs

To copy files from an Ubuntu server to a remote server using SSH and cronjobs in Groovy, you can use the following code:

def command = "scp /path/to/local/file user@remote:/path/to/destination"
def process = command.execute()
if (process.exitValue() != 0) {
    println "File copy failed"

You can then schedule this script to run periodically using cronjobs. To do this, you can add an entry to the crontab using the crontab -e command, and specify the desired schedule for your script.

For example, to run the script every day at 2 AM, you can add the following line to your crontab:

0 2  * groovy /path/to/your/script.groovy

This will execute your Groovy script at 2 AM every day. Make sure to replace "/path/to/your/script.groovy" with the actual path to your script.

Please note that you need to have SSH access to the remote server and the necessary permissions to copy files to the destination path.