Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
I got a website running on a host and I have SSH access to them. I wrote as best as I could a little script to dump the mysql db and compress the directory and sql file into a single file in a folder labeled by the month and day. and then created a crontab to execute it once a month. However towards the end of Jan and through almost the entire first week of Feb it seem to have run everyday but the contents of the backup were empty. But if i run the file manually it works fine.. Im hoping someone here could help me figure what I have wrong.. (I renamed everything to generic stuff)
Im not sure if the crontab is right, Im not familar with it and did the best searching I could to find that.. I basically just want to run this file once a month.
Is there maybe some debug code that could be added to help track down future problems? Not that familar with this stuff created this by just googling various things and trial and error.
Any help you could give I would be greatful! Thanks!!
I know nothing about MySQL, but a couple of things.
1. does the WebBackup script work if you run it from a terminal?
2. is the script executable?
3. crontab entries are along the lines of min hr mday mon dow, so your crontab entry should look something like
30 0 1 * * /full/path/to/script/WebBackup
to run it at 30 past midnight on the 1st of the month
Note you need the path there
Last edited by billymayday; 02-13-2008 at 04:46 AM.
1. Yes when im logged in by SSH I can run it manually and works fine..
2. Yep its executable
3. As far as the path I think thats where I have been running into a little issue. Since this is a host provider I dont have access to any directories below mine. Would I still need to enter the full path? How would I find that since I cant see anything other than my dir?
Thanks to both of you on the crontab correction, I will try changing the first portion now and look more into what path should be set..
1. Yes when im logged in by SSH I can run it manually and works fine..
2. Yep its executable
3. As far as the path I think thats where I have been running into a little issue. Since this is a host provider I dont have access to any directories below mine. Would I still need to enter the full path? How would I find that since I cant see anything other than my dir?
Thanks to both of you on the crontab correction, I will try changing the first portion now and look more into what path should be set..
-D
You should still be able to run it with full path.
Just get the path with `pwd` on the script folder...
Or you could try using it from your home dir ~/folder_of_script/script
Also, try running the script with the full path when you are connected with SSH, to see any possible errors.
Ok, I seem to have got it working by changing everything to the full path that shows up in pwd. Thank you for that.. I also directed the output to a log file for checking errors.
Now I got one last question.. I have 3 sites I run this on so I repeated this code 3 times and changed it with the specific values. I know in programming languages there are ways to simplify this by just supplying the different variables when calling that block of code. Not being a programmer or that Linux savvy I'm kinda lost as to what exactly I should be googling. Is this something thats doable in bash scripts? or am i venturing into the territory of needing to write an app? If it is something I can do could you tell me what specifically I am looking for? Thanks!
Now I got one last question.. I have 3 sites I run this on so I repeated this code 3 times and changed it with the specific values. I know in programming languages there are ways to simplify this by just supplying the different variables when calling that block of code. Not being a programmer or that Linux savvy I'm kinda lost as to what exactly I should be googling. Is this something thats doable in bash scripts? or am i venturing into the territory of needing to write an app? If it is something I can do could you tell me what specifically I am looking for? Thanks!
-D
I think, in your case, you could use environment variables in your bash scripts.
You can read DSL's Wiki for more information.
You don't want to use the -v option for a job running as a cron job. You aren't attached to a console. At the very least, redirect the message output to /dev/null or a file.
Quick question for you guys. My host has a long dir structure in place so when I use the $HOME variable in my tar in the file I have the entire dir structure thats 8 or so dir deep. Is there any way to do the above but not have any of the dir's in the tar from the $HOME variable? if that makes any sense. Thanks!
Anyone know of another compression program I could use that would allow me to not include the $HOME directories? cause really I would just like an archive that contains 2 folders one being the webpage folder and the backup folder that includes the sql dump file. that way I can create a restore script and not have to mess with all the dir's from the host. Thanks!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.