Forum Discussion

Wishaal's avatar
Wishaal
Cloud Apps
02-27-2023
Solved

Cronjob to copy files from local to K8

Hi All, Currently I am using the following kubectl cp /home/ftpifx sisense/`kubectl -n sisense get po -l 'app=management' | awk 'END { print $1 }'`:/opt/sisense/storage/data/informix/ command to...
  • jirazazabal's avatar
    02-27-2023

    Hi,

    You just need to create a bash script in order to make the copy. First of all, get the management pod name:

    #!/bin/bash
    
    localFolder=/path/to/local/files
    management=$(kubectl -n sisense get pods -l app="management" -o custom-columns=":.metadata.name")
    for fileName in `find $localFolder -name '*.csv' -exec basename {} \;` ; do
            kubectl -n sisense cp /home/ftpifx sisense/$fileName $management:/opt/sisense/storage/data/informix/$fileName
    done

    Then, you can add this script to the corntab (make this .sh script executable)

    Best