How to delete evicted pod from k8s by Linux Cron Job/Kubernetes cron job

I am trying to delete evicted pod by Linux cron script,but getting below error

Script is root@k8> cat evicted.sh

!/bin/bash

date echo “Deleting Evcited Pod” /usr/local/bin/kubectl get po -A | grep Evicted | awk ‘{system ("kubectl -n " $1 " delete po " $2)}’

sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found sh: kubectl: command not found

So any idea ,how can I delete it by linux cron job or k8s cron by running a container

You will have to use the complete path of kubectl too in the system call: /use/local/bin/kubectl -n …

The whole path was used,but issue is cron could not trigger kubectl command ,if you have k8s env,you can test also the same

The absolute path to kubectl wasn’t used here.
Did you try adding absolute path in the awk output?