Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Problem with my crontab file, using mysqldump Post 302403116 by Ultrix on Thursday 11th of March 2010 12:49:14 PM
Old 03-11-2010
Problem with my crontab file, using mysqldump

My crontab file tells cron to run a certain shell script at 10:30 AM every day. The shell script backs up my database with mysqldump and then runs a sed script that does some editing of the backup file.

I have programmed the shell script to write an error message to a file I have in my home directory, ~/errorlog.txt, whenever it can't locate the backups directory. I looked in my errorlog file today and found the following messages:

Code:
Tue Mar  9 10:30:00 EST 2010: Error in mysqldump script: can not find backups directory
Thu Mar 11 10:30:00 EST 2010: Error in mysqldump script: can not find backups directory

Here is the script I used:

Code:
#!/bin/bash

olddir=$PWD;
gotomysql > /dev/null;
# alias
if [ -e backups ]
then
    sudo mysqldump Personal > backups/personal.mysql;
    # Lines 24 through 31 are for editing personal.mysql
    if [ -e ~/Desktop/Computer_Stuff/sed_scripts/edit_backup.sed ]
    then
         sed -f ~/Desktop/Computer_Stuff/sed_scripts/edit_backup.sed backups/personal.mysql > temppersonal.mysql;
        cat temppersonal.mysql > backups/personal.mysql;
        rm temppersonal.mysql;
    else echo "$(date): Error in mysqldump script: can not find edit_backup.sed" >> ~/errorlog.txt;
    fi
else echo "$(date): Error in mysqldump script: can not find backups directory" >> errorlog.txt;
fi
cd $olddir;
unset olddir;

The content of the script is not important. I just put it there so you can see what I'm doing. You can skip over it if you don't want to read my sloppy code.

I think I have determined the problem: cron can only run programs when the computer is on and running. When it's asleep, certain things don't work. Obviously, there is no problem with the script, as it appears to have worked on the 10th. I think this is because I was using my computer at the time.

Do you think I diagnosed the problem correctly? Also, is there any way of working around the fact that I can't have my computer active 24/7?
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

mysqldump script without hardcode password

OS: Linux ambglx02 2.6.16.60-0.21-default #1 Tue May 6 12:41:02 UTC 2008 i686 i686 i386 GNU/Linux Shell: bash Currently I have a mysqldump script to backup my mysql database, the command is as below: /opt/novell/mysql/bin/mysqldump --add-drop-table -u root -p -h mydb > /home/john/mydb.sql ... (5 Replies)
Discussion started by: bulkbiz
5 Replies

2. UNIX for Advanced & Expert Users

mysqldump slowing down the process?

Hi All, I have a data calculation process-a perl script running each and every hour which will do some calculations on the data stored in a mysql server. Normally it tooks around 2minutes (max) to complete. But in case if i did any actions on the linux box where the database is... (7 Replies)
Discussion started by: DILEEP410
7 Replies

3. Shell Programming and Scripting

Help needed for mysqldump command

I want to take a backup of a database and redirect the output of the whole process to a log file. I am using the below command: mysqldump -A --add-drop-table > mysql-daily-backup.sql &> /tmp/backup_log/mysql.log Is there anything wrong with the syntax? ---------- Post updated at 08:32 PM... (0 Replies)
Discussion started by: proactiveaditya
0 Replies

4. UNIX for Dummies Questions & Answers

Problem with crontab file

I have a crontab file called /var/spool/cron/root with these contents. When I use the command, crontab -l, these are the contents which are displayed. HOME=/ MAILTO=maintenance@mycompany.com; robl@mycompany.com PATH=/sbin:/bin:/usr/sbin:/usr/bin SHELL=/bin/bash ##run-parts... (2 Replies)
Discussion started by: bobble14988
2 Replies

5. UNIX for Dummies Questions & Answers

Mysqldump certain tables

Hi, I have to upload part of my database periodically when i make changes to product data etc. However I only want to upload certain tables. We suffer from bandwidth chock here, so i want to write a couple of separate scripts that upload parts of the database that changed. The database is large... (5 Replies)
Discussion started by: timgolding
5 Replies

6. Shell Programming and Scripting

Modification of MySQLDump-files before compression needed

Hi @all! In my MySQL-backup-script I backup and compress every single table with this command: /usr/bin/mysqldump --opt database_x table_y | /usr/bin/pbzip2 -c > "/media/BackUpDrive/Backup/table_x.gz"Unfortunately these files need modification - they have to start with the following line(s):... (7 Replies)
Discussion started by: gogo555
7 Replies

7. Shell Programming and Scripting

Mysqldump rotate backup

I have a very simple script that uses a cron job to take a daily backup of our orders database. echo "Dumping ORDERS database"; mysqldump -u root --password='mypassword' -h '1.1.1.1' --opt --compress ORDERS $tbl_names > /Volumes/Files_Backup_1/db_backups/orders.sql echo "Copied database to... (2 Replies)
Discussion started by: timgolding
2 Replies

8. Shell Programming and Scripting

Need Help with automatically Import from special mysqldump

Hi @ all I need a little bit help with a tricky problem ... Here´s the situation: We´ve 2 MySQL-Servers, one is productive, the other is Backup. At the productive Server there runs every 2 hours a cron Job which does a Dump from MySQL-DB with script 'automysqlbackup.sh' and copy it then... (7 Replies)
Discussion started by: jackcracker
7 Replies
CRONTAB(1)						      General Commands Manual							CRONTAB(1)

NAME
crontab - maintain crontab files for individual users (V3) SYNOPSIS
crontab [ -u user ] file crontab [ -u user ] { -l | -r | -e } DESCRIPTION
Crontab is the program used to install, deinstall or list the tables used to drive the cron(8) daemon in Vixie Cron. Each user can have their own crontab, and though these are files in /var, they are not intended to be edited directly. If the allow file exists, then you must be listed therein in order to be allowed to use this command. If the allow file does not exist but the deny file does exist, then you must not be listed in the deny file in order to use this command. If neither of these files exists, then depending on site-dependent configuration parameters, only the super user will be allowed to use this command, or all users will be able to use this command. If the -u option is given, it specifies the name of the user whose crontab is to be tweaked. If this option is not given, crontab examines "your" crontab, i.e., the crontab of the person executing the command. Note that su(8) can confuse crontab and that if you are running inside of su(8) you should always use the -u option for safety's sake. The first form of this command is used to install a new crontab from some named file or standard input if the pseudo-filename ``-'' is given. The -l option causes the current crontab to be displayed on standard output. The -r option causes the current crontab to be removed. The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically. SEE ALSO
crontab(5), cron(8) FILES
/etc/cron.allow /etc/cron.deny STANDARDS
The crontab command conforms to IEEE Std1003.2-1992 (``POSIX''). This new command syntax differs from previous versions of Vixie Cron, as well as from the classic SVR3 syntax. DIAGNOSTICS
A fairly informative usage message appears if you run it with a bad command line. AUTHOR
Paul Vixie <paul@vix.com> 4th Berkeley Distribution 29 December 1993 CRONTAB(1)
All times are GMT -4. The time now is 09:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy