Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
12-18-2003, 03:40 PM
|
#1
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Rep:
|
Shell script running via crontab problem.
Ok, so I'm doing this via my webhost (oktagone). Through Cpanel's UI to crontab. I'm using this script to create a backup of my MySQL database hourly for the times I can't be there to do it myself, I want it time stamped so files are not overwritten (incase the database get's f'ed up, I don't want the backup to be that of a f'ed database).
I'm running this script:
Code:
#!/bin/sh
date=`date -I`
/usr/bin/mysqldump --user=USER --password=PASS --complete-insert --add-drop-table DATABASE | gzip -cf9 > /home/thugg/ibforums$date.gz
Ok, the problem is, the file name contains an illegal char (at least I assume that). I can't delete it, rename it, nothing. I'm going to email them and ask them to do it for me (since they can by inode) I assume that the date variable has a line break character after it, anyone know for sure? I think I may need to add something to remove the illegal char from the date variable, but I'm not sure what the illegal char is, or how to do that. :/
Anyway, if someone could help me rectify this problem, that would be great. I would email them but they'll probably just say "We can have a technician write/correct your script for $30/hour" like they did last time. It's probably a simple fix to those more familier with linux.
Also, the script is being run with the command "/bin/sh /home/thugg/sqlbackup.sh", and I know it's executing (there's about 8 of these backups I can't do s**t with).
Last edited by rshaw; 03-19-2004 at 02:30 PM.
|
|
|
12-18-2003, 04:30 PM
|
#2
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Fist of all, congratulations to your foul language,
we don't see that very often these places.
Secondly, for a diagnosis of the file-name
problem it would help to see the output of
a
ls -l /home/thugg/ibforums*.gz
Cheers,
Tink
|
|
|
12-18-2003, 04:51 PM
|
#3
|
Member
Registered: Dec 2003
Location: Al-Diwania, Iraq (deployed)
Distribution: Slackware ONLY
Posts: 237
Rep:
|
man tar
man cpio
and the bash programming how to
and the sh how to
should tell you how to make properly dated backups that u can use.
|
|
|
12-18-2003, 05:45 PM
|
#4
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Original Poster
Rep:
|
Quote:
Originally posted by Tinkster
[B]Fist of all, congratulations to your foul language,
we don't see that very often these places.
|
Yeah, sorry about that, it's my normal everyday language.
Since I don't have a shell access via telnet or something else, It's not easy for me to do ls, I would have to do it as a cron job that outputs to a file so I can read it. As for the man pages I've read a few. I mainly went off of mysqldump at mysql.com. It's where I originally found the $date thing. I'll read the other ones, though I don't want to tar the output, I just wanted to exactly the same as cpanel does it (and so for the mysqldump command with those options is exactly that, aswell as the gzip). I just wanted it automated and time stamped so It would never overwrite.
|
|
|
12-19-2003, 12:26 AM
|
#5
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Original Poster
Rep:
|
Ok, I did the ls (cheaply using crontab, lol). I used the long, all and inode options (-lia). Now I can at least delete via the inode, anyway.
Code:
4088551 -rw-r--r-- 1 thugg thugg 485628 Dec 18 15:20 /home/thugg/ibforums-2003-12-18
.gz
NOTE: The reason for the line break is because the output has the line break char in the file name, so it is infact the line break character. Also I cropped the output to this single line, 'tis all that's needed.
Now I hope all I need is a line to remove the line break from the $date variable, can anyone help me with that? (I've searched quite a bit today, I only found, err 'stuff' for perl and html).
|
|
|
12-19-2003, 11:52 AM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Code:
date=`date -I|tr -d \\012`
Cheers,
Tink
|
|
|
12-19-2003, 12:01 PM
|
#7
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Original Poster
Rep:
|
I will test, but I assume it shall work. I've been messing with tr too, doesn't want to work for me, but I think my syntax was off, and I didn't try it using a pipe.
|
|
|
12-19-2003, 12:06 PM
|
#8
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Original Poster
Rep:
|
Well, unfortunatly that did not work. It resaulted in this file:
Code:
4088873 -rw-r--r-- 1 thugg thugg 491859 Dec 19 13:02 ibforums3--9
.gz
With a linebreak after the 9..
Last edited by thetruethugg; 12-19-2003 at 12:07 PM.
|
|
|
12-19-2003, 12:16 PM
|
#9
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Sorry, I had only tried it from a command-line...
Try this
Code:
date="`date -I | tr -d '\\012'`"
Cheers,
Tink
|
|
|
12-19-2003, 01:10 PM
|
#10
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Original Poster
Rep:
|
Hmm, well this time the date is there, but the linebreak is still after it, followed by the extension (which I can't see via FTP because the I can't see anything after the line break. I tried replacing the \\012 with \n, but neither worked.
I'm begining to think maybe this is hopeless, but then again I'm by no means optimistic. Or at least that the $30/hour isn't such a rip-off.
Thanks for your help though, and if you have any more ideas, just let me know.
|
|
|
12-19-2003, 02:13 PM
|
#11
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Just out of curiosity: what OS is the site hosted on? ;)
Cheers,
Tink
|
|
|
12-19-2003, 02:18 PM
|
#12
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Original Poster
Rep:
|
Red Hat 9.0
|
|
|
12-19-2003, 07:23 PM
|
#13
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Still don't understand WHY it does that, but try
this one:
Code:
#!/bin/sh
file=/home/thugg/ibforums-`date -I`.gz
/usr/bin/mysqldump --user=USER --password=PASS --complete-insert --add-drop-table DATABASE | gzip -cf9 > $file
Cheers,
Tink
|
|
|
12-19-2003, 08:56 PM
|
#14
|
LQ Newbie
Registered: Aug 2002
Location: lincoln
Distribution: SuSE 8.0 Personal
Posts: 13
Original Poster
Rep:
|
Ok, now there's no more return characters or anything wierd like that in the name, but FTP says can't find file (no such file or directory), and cpanel's filemanager says can't stat file, because it doesn't exist. Lol.
ls -lia /home/thugg/* output:
Code:
4088877 -rw-r--r-- 1 thugg thugg 495552 Dec 19 21:43 /home/thugg/ibforums-2003-12-19.gz
I also tried `date +%d%m%y%k%M` incase for some odd reason it was the hyphens, still no luck. File is right there, but it says it can't find it when I try to do anything with it via FTP or cpanel's file manager.
|
|
|
All times are GMT -5. The time now is 06:39 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|