Results 1 to 6 of 6

Thread: crontab & mysqldump

  1. #1
    Snojlsky NNTP User

    Default crontab & mysqldump

    Hi,

    Im trying to schedule a mysqldump with crontab as root.. but cant get it to work.

    My cron expression is ok and the mysqldump line (i can run other task with the expression and manually start the mysqldump)

    I get no errors (that i can find), it simply dont create a sql dump

    I use the full path to the mysqldump executable, is the environment different from root:s when a cron expression is fired somehow?

    Anyone got an idea?

    Regards
    Snoj
    (Im a Linux newbie)

  2. #2
    Join Date
    Jun 2008
    Location
    West Yorkshire, UK
    Posts
    3,439

    Default Re: crontab & mysqldump

    For security reasons openSUSE is set up to prevent you logging into mysql from root. That doesn't apply if you use mysqldump after su -- as an ordinary user. So, and I'm not sufficiently conversant with cron to know how to do that, if you can set up a cron task under a user using su or sudo, I assume it would work.

  3. #3
    Snojlsky NNTP User

    Default Re: crontab & mysqldump

    ok, thanks!!!

    Il try to use a normal user account instead of root.

    /Snoj

  4. #4
    Join Date
    Jun 2008
    Location
    /dev/belgium
    Posts
    1,946

    Default Re: crontab & mysqldump

    you may also want to look into this dumpmysql CLI-Apps.org

    alternatively you can get it from my repo too

  5. #5
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: crontab & mysqldump

    I have a mysqldump job running from a root cron job and it works fine.

    The thing to remember is that when you run any mysql program from an account, the default mysql user is the account user. You can override this with -u user. You don't show your command or your setup so we have no idea what user you are meant to use.

    This also means that you don't have to run mysqldump as root but from any account, since the mysql accounts are separate from Linux login accounts.

    BTW, the MySQL online manual shows various ways of providing the password for an non-interactive mysql program. Safest is to put it in a section of $HOME/.my.cnf and make sure the permissions of that are 0600 or 0400.

  6. #6
    Snojlsky NNTP User

    Default Re: crontab & mysqldump

    It was really stupid on my part… I didn’t supply I path to where I wanted my sql dump, and when testing I where in the folder I wanted it in. Cron/mysqldump as root worked out just fine, the sql dump was simply saved in my home account path.

    I will definitely try to use $HOME/.my.cnf, now I supply the password in clear text with –p & -u

    Sorry and thanks!

Posting Permissions

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