LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-06-2013, 08:58 PM   #1
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Rep: Reputation: Disabled
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-
 
Old 01-07-2013, 06:47 AM   #2
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
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
 
Old 01-07-2013, 07:11 AM   #3
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 981
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
Quote:
Originally Posted by barathan View Post
nice: /etc/cron.hourly/FILEMOV02.py: No such file or directory
Does /etc/cron.hourly/FILEMOV02.py exist? Can it be run from a shell prompt?
 
Old 01-07-2013, 07:15 AM   #4
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
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-
 
Old 01-07-2013, 07:39 AM   #5
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 981
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
What about calling "/etc/cron.hourly/FILEMOV02.py" on its own? Does /usr/bin/python exist?
 
1 members found this post helpful.
Old 01-07-2013, 09:42 PM   #6
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
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
 
Old 01-07-2013, 10:53 PM   #7
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
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?
 
Old 01-07-2013, 11:32 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,117

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
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).
 
1 members found this post helpful.
Old 01-08-2013, 01:05 AM   #9
barathan
LQ Newbie
 
Registered: Jun 2012
Posts: 17

Original Poster
Rep: Reputation: Disabled
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios - Return code of 127 for check of service sriramsreedhar Linux - General 5 11-14-2016 03:32 PM
cron.hourly cron.weekly cron.monthly and 0anacron. Are they necessary? glore2002 Debian 2 09-30-2009 09:57 PM
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 09:09 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 07:37 PM
script in cron.hourly not running hourly unholy Linux - Software 2 09-19-2006 09:21 PM


All times are GMT -5. The time now is 01:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration