Find the answer to your Linux question:
Results 1 to 3 of 3
I have my own Ubuntu 8.10 server, on which a slave MySql database is running. I want to make hourly backups and wrote this script with the name backup2: ------------------------------------------------------------------------------------- ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2009
    Posts
    2

    [SOLVED] Can't get script to work under crontab


    I have my own Ubuntu 8.10 server, on which a slave MySql database is running. I want to make hourly backups and wrote this script with the name backup2:

    -------------------------------------------------------------------------------------

    #!/bin/bash
    export DISPLAY=:0.0
    datum=`date +"%Y%m%d%H%M"`
    wachtwoord=xxxxxxx

    echo "wachtwoord = $wachtwoord"
    echo "datum = $datum"
    mysqladmin -u root -p$wachtwoord stop-slave;

    mysqldump -u root -p$wachtwoord --lock-all-tables admin_betersys > /home/rob/backups/backup3-$datum.sql

    mysqladmin -u root -p$wachtwoord start-slave;

    --------------------------------------------------------------------------------------

    this script runs fine if I start it manualy: ./backup2

    I tried to put this in crontab, and it seems to work:

    rob-at-UbuntuServer:~$ crontab -l
    # 20 * * * * ./backup2
    # 59 * * * * /home/rob/backup2

    As you can see I tried various times and notations.

    I also restart cron each time I make a change to crontab:

    rob-at-UbuntuServer:~$ sudo /etc/init.d/cron restart
    [sudo] password for rob:
    * Restarting periodic command scheduler crond [ OK ]

    But no luck, the backup isn't made at the scheduled time. What am I overlooking ?

    TIA,

    Rob

  2. #2
    Linux Enthusiast Bemk's Avatar
    Join Date
    Sep 2008
    Location
    Oosterhout-NB, Netherlands
    Posts
    525
    In Cron you will need the direct path, and I would uncomment the line if I were you(removing the '#').

    By the way, nice to know another person who speaks Dutch, on the forums.

  3. #3
    Just Joined!
    Join Date
    May 2009
    Posts
    2

    Thanks a lot

    I knew it had to be something simple, I just adjusted the sample line in crontab and didn't notice the #
    Now I know I should have kept the sample line and added my own lines. However, it works now so thanks a lot.

    BTW, there are more dutch people on the net, but you're right, it's always nice to meet one.

    Rob

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •