jdoe
jdoe

Reputation: 79

crontab logs command not found

I have a crontab

50 11 * * * root /home/user/web/domain.com/python/stepn/cron.sh >> /home/user/web/domain.com/python/stepn/cronlogs.log 2>&1

the contents of cron.sh are

/home/user/web/domain.com/python/stepn/venv/bin/python /home/user/web/domain.com/python/stepn/get.py

the sh file works from the command line. Whenever the cron runs the log file contains

/bin/bash: root: command not found

the -R permissions on the stepn folder are user:wheel

I changed the group to wheel so that root had permissions to the folder. I don't know if I needed to so that. Previously it was user:user

I notice the python is a shortcut to /opt/rh/rh-python38/root/usr/bin/python

I don't know what else to try, to get the cron to work.

Upvotes: 0

Views: 713

Answers (1)

Holger Just
Holger Just

Reputation: 55768

Depending on where exactly you define your crontab entries, the user column (in your case set to root) is not expected and supported.

This is for example the case when editing your crontabs using the crontab -e command. Here, the user which should run the command is implicitly set to the user whose crontab you are editing.

In your case, cron does not expect a username after the time specification and thus assumes that it should run the following command:

root /home/user/web/domain.com/python/stepn/cron.sh >> /home/user/web/domain.com/python/stepn/cronlogs.log 2>&1

As you don't have an executable named root, this fails. To fix this, make sure you define your crontab entry in the right context and/or get rid of the user name specification there if the user is implied.

Upvotes: 1

Related Questions