LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 10-26-2006, 02:37 PM   #1
mokelly1
LQ Newbie
 
Registered: Jan 2004
Location: Royse City, Texas
Distribution: Suse 10
Posts: 11

Rep: Reputation: 0
cron script - No such file or directory


It is in the man pages and in all the how to's but as a newbie (for only 3 years) I cannot seem to figure it out. I have 3 Suse 10 servers running cron jobs without a hitch although it was like pulling teeth to get them to work. It took so long to get these working that I have gone stare crazy and cannot see the problem here.

I want to run the following cron job on the 4th server named BTI.sh.


#!/bin/sh
/usr/bin/rsync -rutv --modify-window=1 /srv/www/htdocs /mnt/SuseBackup/BTI-Intranet/Scripts;
/usr/bin/mysqlhotcopy Intranet /root/Backup/Data --user=root --password=mypassword --allowold;
/usr/bin/rsync -rutv --modify-window=1 /root/Backup/Data/Intranet /mnt/SuseBackup/BTI-Intranet/Data;

Here is a strange observation. Without semicolons in the above script I get:


bti-intranet:/etc/cronsOther # sh BTI.sh
building file list ... done
rsync: mkdir "/mnt/SuseBackup/BTI-Intranet/Scripts\015" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(422)
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(434)
Unknown option: allowold
Invalid option
/usr/bin/mysqlhotcopy Ver 1.22

Usage: /usr/bin/mysqlhotcopy db_name[./table_regex/] [new_db_name | directory]

-?, --help display this helpscreen and exit
-u, --user=# user for database login if not current user
-p, --password=# password to use when connecting to server (if not set
in my.cnf, which is recommended)
-h, --host=# Hostname for local server when connecting over TCP/IP
-P, --port=# port to use when connecting to local server with TCP/IP
-S, --socket=# socket to use when connecting to local server

--allowold don't abort if target dir already exists (rename it _old)
--addtodest don't rename target dir if it exists, just add files to it
--keepold don't delete previous (now renamed) target when done
--noindices don't include full index files in copy
--method=# method for copy (only "cp" currently supported)

-q, --quiet be silent except for errors
--debug enable debug
-n, --dryrun report actions without doing them

--regexp=# copy all databases with names matching regexp
--suffix=# suffix for names of copied databases
--checkpoint=# insert checkpoint entry into specified db.table
--flushlog flush logs once all tables are locked
--resetmaster reset the binlog once all tables are locked
--resetslave reset the master.info once all tables are locked
--tmpdir=# temporary directory (instead of /tmp)
--record_log_pos=# record slave and master status in specified db.table
--chroot=# base directory of chroot jail in which mysqld operates

Try 'perldoc /usr/bin/mysqlhotcopy' for more complete documentation
building file list ... done
rsync: mkdir "/mnt/SuseBackup/BTI-Intranet/Data\015" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(422)
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(434)


With the semicolons I get a 'command not found' for each semicolon but it works:

bti-intranet:/etc/cronsOther # sh BTI.sh
building file list ... done

sent 19845 bytes received 20 bytes 39730.00 bytes/sec
total size is 35819869 speedup is 1803.16
: command not found
Existing hotcopy directory renamed to '/root/Backup/Data/Intranet_old'
Locked 27 tables in 0 seconds.
Flushed tables (`Intranet`.`ActionLinks`, `Intranet`.`Actions`, `Intranet`.`ConsignmentPurchaseOrder`, `Intranet`.`ControlPoints`, `Intranet`.`EMailQue`, `Intranet`.`Employee`, `Intranet`.`FeederAudit`, `Intranet`.`Forecast`, `Intranet`.`ForecastMonth`, `Intranet`.`Job`, `Intranet`.`Labor`, `Intranet`.`Layout`, `Intranet`.`PartCategories`, `Intranet`.`PartsPrices`, `Intranet`.`People`, `Intranet`.`ProcessThread`, `Intranet`.`Processes`, `Intranet`.`QualityAlertStatusCodes`, `Intranet`.`QualityAlerts`, `Intranet`.`RackParts`, `Intranet`.`SMTCycleTimes`, `Intranet`.`SMTPartNotes`, `Intranet`.`SubstituteParts`, `Intranet`.`TimeAbsentTardy`, `Intranet`.`TimeCards`, `Intranet`.`TopLevelRevisions`, `Intranet`.`Triggers`) in 0 seconds.
Copying 82 files...
Copying indices for 0 files...
Unlocked tables.
mysqlhotcopy copied 27 tables (82 files) in 1 second (1 seconds overall).
: command not found
building file list ... done
Intranet/
Intranet/Actions.MYD
Intranet/Actions.MYI
Intranet/Labor.MYD
Intranet/Labor.MYI
Intranet/TimeAbsentTardy.MYD
Intranet/TimeAbsentTardy.MYI

sent 26658597 bytes received 158 bytes 5924167.78 bytes/sec
total size is 34603952 speedup is 1.30
: command not found


Here is my crontab for root:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/root/BTICrontab installed on Thu Oct 26 13:45:44 2006)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
MAILTO=mkelly@bottomstechnology.com
SHELL=/bin/sh
PATH=/bin:/usr/bin:
47 * * * * /etc/cronsOther/BTI.sh

I get the following email:

/bin/sh: /etc/cronsOther/BTI.sh
: No such file or directory

Here is the directory:

bti-intranet:/etc/cronsOther # dir
total 20
drwxr-xr-x 2 root root 120 Oct 26 13:45 .
drwxr-xr-x 94 root root 8320 Oct 26 11:23 ..
-rwxrwxr-x 1 root root 301 Oct 26 13:45 BTI.sh
-rwxrwxr-x 1 root root 301 Oct 26 13:45 BTI.sh~
-rwxr-xr-x 1 root root 196 Oct 25 15:15 test
bti-intranet:/etc/cronsOther #

I must be overlooking something simple. Thank you for your help!
 
Old 10-26-2006, 05:29 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
If I read that right, without the semi-colons the script is being treated as one long (mangled) command. Did you create the script under Windows instead of Linux? The line endings might be DOS style instead of UNIX.

You could try the following:
Code:
fromdos < /etc/cronsOther/BTI.sh > /etc/cronsOther/BTI-new.sh
If you don't have fromdos, you may have dos2unix. I think the syntax is:
Code:
dos2unix /etc/cronsOther/BTI.sh
 
Old 10-26-2006, 07:07 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
What filesystem type do you store this script on?
 
Old 10-27-2006, 10:13 AM   #4
mokelly1
LQ Newbie
 
Registered: Jan 2004
Location: Royse City, Texas
Distribution: Suse 10
Posts: 11

Original Poster
Rep: Reputation: 0
Created with Gedit on Suse 10

I created the script using Suse 10 - Gedit and stored it on the hard drive of the Linux box. The hard drive was partitioned by the Suse 10 install and I chose the default settings. Nothing unusual here. However, I did email the script from the first Linux machine to a Windows machine opened and saved it to the latest Linux drive. The 'dos2unix /etc/cronsOther/BTI.sh' fixed the bad command issue when running BTI.sh from the command line.

However, I still get:


/bin/sh: /etc/cronsOther/BTI.sh
: No such file or directory

from cron executing it?
 
Old 10-27-2006, 10:33 AM   #5
mokelly1
LQ Newbie
 
Registered: Jan 2004
Location: Royse City, Texas
Distribution: Suse 10
Posts: 11

Original Poster
Rep: Reputation: 0
Well gilead, your geniusity is validated once again. I ran the dos2unix command on BTI.sh, those pesky dos cr and lf's went away and the script was found and executed properly by cron.

Many thanks!
 
Old 10-27-2006, 02:31 PM   #6
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
That's good news - I mean the bit about it working
 
  


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
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
Directory file size script yeahflow Linux - Newbie 4 09-03-2006 07:29 PM
script.sh - No such file or directory - ??? ilhbutshm Programming 5 05-26-2004 10:26 AM
Run script during file copy or create in directory neranjana Linux - General 1 01-13-2004 06:57 AM
Running a script on every file in a directory davee Linux - Newbie 2 11-04-2003 02:34 PM


All times are GMT -5. The time now is 07:19 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration