0

Hi I'm getting this error when running the shell script using crontab for the specific user

this my crontab:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
29 22 * * * automation /home/automation/profilecheck/untitled.sh >> /home/automation/profilecheck/profilecheck.log 2>&1

anyone can help with this issue?

Henry
  • 5
  • 3

1 Answers1

3

Cron jobs running with crontab -e are run as the user who issues that command and thus owns that cronjob. You need to remove the user automation from your command and create/run the cronjob from automation user account.

29 22 * * * /home/automation/profilecheck/untitled.sh >> /home/automation/profilecheck/profilecheck.log 2>&1

O Or you can add your cronjob into /etc/crontab

Or move your cronjob to /etc/cron.d and make sure the user is available and has relevant permissions.

deepakchethan
  • 5,240
  • 1
  • 23
  • 33
  • if i remove the user(automation) the cronjob is running but it's getting an permission denied error when trying to ssh to other server. – Henry Jun 18 '21 at 03:05
  • i added /home to the path and Im getting different error now. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home /bin/sh: 1: automation: Permission denied – Henry Jun 18 '21 at 03:06
  • If you want the user then can you move it to `/etc/cron.d` and let the system run it with the user? – deepakchethan Jun 18 '21 at 03:22
  • so i just need to move my crontab file to /etc/cron.d folder? – Henry Jun 18 '21 at 03:38
  • Yes, or you try updating /etc/crontab also, I have updated the answer – deepakchethan Jun 18 '21 at 04:08