Sample Header Ad - 728x90

pkill -P variable not working when running .sh under cron

0 votes
3 answers
1670 views
I have a very simple .sh script to kill a process. The processes saves its PID to pid2.txt. 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?
Asked by sjaak (644 rep)
Jun 21, 2018, 05:29 AM
Last activity: Jan 8, 2021, 08:55 AM