cron.hourly : return code 127
hello all,
i have created a simple python script that will move log files from one linux machine to another linux machine. i placed this script in cron.hourly (my machine is LINUX Open Suse). eventually, my script doesnt run hourly. checked in /var/mail/root, saw below message : running hourly cronjob scripts SCRIPT: FILEMOV02.py exited with RETURNCODE = 127. SCRIPT: output (stdout && stderr) follows nice: /etc/cron.hourly/FILEMOV02.py: No such file or directory SCRIPT: FILEMOV02.py ------- END OF OUTPUT could anyone help me please? below is my python script : #!/usr/bin/python import os import time import glob filePath = r"/usr/local/testlogs/parse/*.*" serverPath = r"/usr/local/testlogs/DB_parse" try : files = glob.glob(filePath) for f in files : os.system("scp "+f+" root@192.168.10.1:"+serverPath) time.sleep(1) #delay 1 sec before file gets deleted one by one os.remove(f) except OSError: print "parse directory is missing!!" -thanks- |
adding more info : this is my crontab
SHELL=/bin/sh PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin MAILTO=root # # check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly # -*/27 * * * * root test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1 |
Quote:
|
hi there!
yes, this file exists in /etc/cron.hourly and i gave 777 permission for this file. it works fine on the terminal when i run "python FILEMOV02.py" i think there's something wrong with the environment. but since i'm a newbie, i need step by step guidance. -thanks- |
What about calling "/etc/cron.hourly/FILEMOV02.py" on its own? Does /usr/bin/python exist?
|
yes, /usr/bin/python exist. how do you want me to call /etc/cron.hourly/FILEMOV02.py? i was able able to go to directory /etc/cron.hourly and run the script by typing python FILEMOV02.py, and didnt see any issue
|
ok, so now in gnome terminal, i typed "/etc/cron.hourly/FILEMOVE02.py" and got below error message :
-bash: /etc/cron.hourly/FILEMOV02.py: /usr/bin/python^M: bad interpreter: No such file or directory any idea what is this please? |
The file was created by a Windows/DOS editor and has DOS-style line endings (CR-LF). You need to run dos2unix on the file to change to Unix-style endings (LF).
|
absolutely! i just solved this :
in gnome terminal, type "cat FILEMOV02.py | col -b > FILEMOV03.py" i dont see the ^M error message anymore! thank very much everybody! |
All times are GMT -5. The time now is 09:21 PM. |