Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
-?, --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!
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.