Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [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:


    export DISPLAY=:0.0
    datum=`date +"%Y%m%d%H%M"`

    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 ?



  2. #2
    Linux Enthusiast Bemk's Avatar
    Join Date
    Sep 2008
    Oosterhout-NB, Netherlands
    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

    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.


  4. $spacer_open

Posting Permissions

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