Skip to main content
added 15 characters in body
Source Link
Fixed formatting
Source Link
jsbillings
  • 24.9k
  • 7
  • 58
  • 58

Logged in as a regular user trying to schedule a cron job to run every minute on RHEL8. Python script runs fine when executed at terminal as ./python.py but giving me an error when run as a job in crontab. Below are the absolute paths, got by "which python3" and "realpath -e python.py". given chmod 777 permissions to python.py.

crontab -e

          • /usr/bin/python3 /home/user/test_1/test/python.py >> /home/user/test_1/test/cron.log 2>&1
* * * * * /usr/bin/python3   /home/user/test_1/test/python.py >>  /home/user/test_1/test/cron.log 2>&1

error :

Traceback (most recent call last):

File "/home/user/test_1/test/python.py", line 127, in

Traceback (most recent call last):

File "/home/user/test_1/test/python.py", line 127, in <module>
 log_location = config.log_file_location()

File "/home/user/test_1/test/config.py", line 62, in log_file_location

File "/home/user/test_1/test/config.py", line 62, in log_file_location
 baseLoc = self.base_data_location()

File "/home/user/test_1/test/config.py", line 56, in base_data_location

File "/home/user/test_1/test/config.py", line 56, in base_data_location
 baseDirPath = self.cb_config.get('base_data_dir', '/tmp')
AttributeError: 'NoneType' object has no attribute 'get'
Exception reading config: No section: 'test_connection'
Exception reading config: No section: 'product_info'
Exception reading config: No section: 'event_ids

AttributeError: 'NoneType' object has no attribute 'get'

Exception reading config: No section: 'test_connection'

Exception reading config: No section: 'product_info'

Exception reading config: No section: 'event_ids

Logged in as a regular user trying to schedule a cron job to run every minute on RHEL8. Python script runs fine when executed at terminal as ./python.py but giving me an error when run as a job in crontab. Below are the absolute paths, got by "which python3" and "realpath -e python.py". given chmod 777 permissions to python.py.

crontab -e

          • /usr/bin/python3 /home/user/test_1/test/python.py >> /home/user/test_1/test/cron.log 2>&1

error :

Traceback (most recent call last):

File "/home/user/test_1/test/python.py", line 127, in

log_location = config.log_file_location()

File "/home/user/test_1/test/config.py", line 62, in log_file_location

baseLoc = self.base_data_location()

File "/home/user/test_1/test/config.py", line 56, in base_data_location

baseDirPath = self.cb_config.get('base_data_dir', '/tmp')

AttributeError: 'NoneType' object has no attribute 'get'

Exception reading config: No section: 'test_connection'

Exception reading config: No section: 'product_info'

Exception reading config: No section: 'event_ids

Logged in as a regular user trying to schedule a cron job to run every minute on RHEL8. Python script runs fine when executed at terminal as ./python.py but giving me an error when run as a job in crontab. Below are the absolute paths, got by "which python3" and "realpath -e python.py". given chmod 777 permissions to python.py.

crontab -e

* * * * * /usr/bin/python3   /home/user/test_1/test/python.py >>  /home/user/test_1/test/cron.log 2>&1

error :

Traceback (most recent call last):

File "/home/user/test_1/test/python.py", line 127, in <module>
 log_location = config.log_file_location()
File "/home/user/test_1/test/config.py", line 62, in log_file_location
 baseLoc = self.base_data_location()
File "/home/user/test_1/test/config.py", line 56, in base_data_location
 baseDirPath = self.cb_config.get('base_data_dir', '/tmp')
AttributeError: 'NoneType' object has no attribute 'get'
Exception reading config: No section: 'test_connection'
Exception reading config: No section: 'product_info'
Exception reading config: No section: 'event_ids
Source Link

Python script not running in crontab

Logged in as a regular user trying to schedule a cron job to run every minute on RHEL8. Python script runs fine when executed at terminal as ./python.py but giving me an error when run as a job in crontab. Below are the absolute paths, got by "which python3" and "realpath -e python.py". given chmod 777 permissions to python.py.

crontab -e

          • /usr/bin/python3 /home/user/test_1/test/python.py >> /home/user/test_1/test/cron.log 2>&1

error :

Traceback (most recent call last):

File "/home/user/test_1/test/python.py", line 127, in

log_location = config.log_file_location()

File "/home/user/test_1/test/config.py", line 62, in log_file_location

baseLoc = self.base_data_location()

File "/home/user/test_1/test/config.py", line 56, in base_data_location

baseDirPath = self.cb_config.get('base_data_dir', '/tmp')

AttributeError: 'NoneType' object has no attribute 'get'

Exception reading config: No section: 'test_connection'

Exception reading config: No section: 'product_info'

Exception reading config: No section: 'event_ids