I'm trying to run a cron job that executes a script as a user using crontab -e on ubuntu server 16.04 LTS. The script is and located in /data/autoremove.sh:
if ping -q -c 1 -W 1 220.127.116.11 >/dev/null; then scp /data/Data* email@example.com:/data && rm data* else echo "does not work" fi
and the cron job is being configured with the user "user":
*/1 * * * * /data/autoremove.sh>/dev/null 2> ~/cron.err.
I have tried adding both a
SHELL=/bin/bash and a
PATH= to both the crontab and the script, and confirmed that cron is running, and attempted to run it without declaring a user. The script works when running it either as root or the owner
The error I am getting is
/bin/bash: user: command not found' I've gone through multiple articles on the different stacks sites and not had any luck getting this to work.