I have a very simple
.sh script to kill a process. The processes saves its PID to
pkill -e -P $(cat pid2.txt) exit
When I run this as
sudo ./myscript.sh from the command line it works fine.
When run by cron as
*/2 * * * * /etc/mylocation/myscript.sh it throws an error:
cat: pid2.txt: No such file or directory pkill: option requires an argument -- 'P'
What am I doing wrong?