LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 11-21-2013, 11:34 AM   #1
bugrake
LQ Newbie
 
Registered: Nov 2013
Location: Galway, Ireland
Distribution: Centos 6.4
Posts: 5

Rep: Reputation: Disabled
run cp script as batch or cron job


Hi,
Centos 6.4 - hosted remotely

I am new to linux and normally do uploads and downloads using
ftp and monitor via webmin. However, I have a large data file [26GB] I am trying to copy the file out of the data area to pull it off the server

Trying to cp the file I have twice bought the server to a standstill and had the session terminated after about 15GB. So I would like to put this copy in a low priority batch job ( data file will be write locked).

this is my script - [ stock_copy.sh ]

#!/bin/sh
# dump stock file
#
nice -n 20 ionice -c 3 cp /var/lib/mysql/live01/stock01.MYI /home/backup/dump



- i did
$ at now + 5 minutes > stock_copy.sh

and nothing happened!!

Is the script OK ? How can I view the queue ? Is there a log file so I can check for errors

thanks for any help.
 
Old 11-21-2013, 11:39 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 979
Blog Entries: 2

Rep: Reputation: 235Reputation: 235Reputation: 235
echo stock_copy.sh | at now + 5 minutes

You probably damaged your script file by pointing a > at it.
 
2 members found this post helpful.
Old 11-21-2013, 11:41 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,026

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
Quote:
Originally Posted by bugrake View Post
...
- i did
$ at now + 5 minutes > stock_copy.sh

and nothing happened!!

Is the script OK ? How can I view the queue ? Is there a log file so I can check for errors

thanks for any help.
man atq

also, did you wait 5 minutes like you instructed the command to.
edit: i think it should be
Code:
at now + 5 minutes -f stock_copy.sh

Last edited by schneidz; 11-21-2013 at 11:51 AM.
 
1 members found this post helpful.
Old 11-21-2013, 12:37 PM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,261

Rep: Reputation: 297Reputation: 297Reputation: 297
Hi

The file is an index file to a mysql database table. It can be re-created from the corresponding .frm and .MYD. So copying for backup is a bit pointless. Use mysqldump if you want a backup. If you delete the file, mysql will get problems. And I think the real reason is probably because there are too many indexes on the table, or there's simply too much data in the table. I would use webmin or phpmyadmin to check and possibly delete. The database name is live01 and the table name is stage01. How big is "/var/lib/mysql/live01/stock01.MYD"?
 
1 members found this post helpful.
Old 11-21-2013, 04:26 PM   #5
bugrake
LQ Newbie
 
Registered: Nov 2013
Location: Galway, Ireland
Distribution: Centos 6.4
Posts: 5

Original Poster
Rep: Reputation: Disabled
thanks you for speedy replies

linosaurusroot- firstly the script file did appear to have lost its header but I had subsequently opened it in vi (wow - there's another story) and thought this had caused the problem. I will retry with a clean script file and the corrected syntax

shneidz - i waited 5 minutes and more , i will have a look at man atq

guttorm - you are quite correct I have listed the index file which is 6GB in this case, and I copied that using cp at the terminal, I put it in the script file to test a smaller copy on the test system. It is the MYD file that is huge, mysqldump works fine on smaller files but it blocks the mysql processing on this file and I eventually lose network connection. It's too big I know - I have just inherited it.

For now I would like to nail how to submit a script ,that hopefully copies a file and creates a log, part of my linux adventure ..
 
Old 11-29-2013, 11:37 AM   #6
bugrake
LQ Newbie
 
Registered: Nov 2013
Location: Galway, Ireland
Distribution: Centos 6.4
Posts: 5

Original Poster
Rep: Reputation: Disabled
I had 2 problems

1. The shell script was corrupted and also had CR LF on the end of each line - used Notepad++ Edit> EOL conversion > Unix to fix to LF

2. Used the correct syntax ... at now + 5 minutes -f stock_copy.sh

All OK now - thanks for the help
 
  


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
[SOLVED] Empty email when the script run as a cron job jf.argentino Linux - Server 3 01-07-2013 03:45 AM
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 09:26 PM
Script works when run manually but not in cron job Harlin Linux - Software 7 10-16-2007 07:36 PM
script does not run in cron job kashyapvirgo Linux - General 8 03-20-2007 11:55 AM
shell script fo run auto job in cron JolynnMarie LinuxQuestions.org Member Intro 0 04-28-2004 12:21 PM


All times are GMT -5. The time now is 06:01 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