Results 1 to 7 of 7

Thread: Cron job

  1. #1
    Join Date
    Jun 2017
    Location
    ZS
    Posts
    50

    Cron job

    Hi I have script for backup (every 50 minut) from command line it works but when I add this command to cron job (user) it's shout that
    mkdir: cannot create directory ‘/home/szukamprac/backupmysql/2017-09-01’: Permission denied
    chmod's are ok, folder is in home/user

    Ok, i create all script and folder from this user and this work's form command line but not from cron tab for this user
    bash: /home/szukamprac/mysqlbackup.sh: Permission denied

    problem solved
    Last edited by Mattpl; 09-01-2017 at 01:51 AM.

  2. #2
    Join Date
    Jun 2017
    Location
    ZS
    Posts
    50
    Hi another problem with cron.daily
    Error log
    /etc/cron.daily/logrotate:
    error: error running shared postrotate script for '/var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/error.log '
    run-parts: /etc/cron.daily/logrotate exited with return code 1
    Password for deb-sys is OK, made this GRANT RELOAD, SHUTDOWN, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY PASSWORD 'xxxxxxxxxxxxxxxx' and still the same problem

    Command : logrotate -f -v /etc/logrotate.d/mysql-server
    reading config file /etc/logrotate.d/mysql-server

    Handling 1 logs

    rotating pattern: /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/error.log forced from command line (7 rotations)
    empty log files are rotated, old logs are removed
    considering log /var/log/mysql.log
    log needs rotating
    considering log /var/log/mysql/mysql.log
    log needs rotating
    considering log /var/log/mysql/mysql-slow.log
    log needs rotating
    considering log /var/log/mysql/error.log
    log needs rotating
    rotating log /var/log/mysql.log, log->rotateCount is 7
    dateext suffix '-20171023'
    glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
    renaming /var/log/mysql.log.7.gz to /var/log/mysql.log.8.gz (rotatecount 7, logstart 1, i 7),
    old log /var/log/mysql.log.7.gz does not exist
    renaming /var/log/mysql.log.6.gz to /var/log/mysql.log.7.gz (rotatecount 7, logstart 1, i 6),
    old log /var/log/mysql.log.6.gz does not exist
    renaming /var/log/mysql.log.5.gz to /var/log/mysql.log.6.gz (rotatecount 7, logstart 1, i 5),
    old log /var/log/mysql.log.5.gz does not exist
    renaming /var/log/mysql.log.4.gz to /var/log/mysql.log.5.gz (rotatecount 7, logstart 1, i 4),
    old log /var/log/mysql.log.4.gz does not exist
    renaming /var/log/mysql.log.3.gz to /var/log/mysql.log.4.gz (rotatecount 7, logstart 1, i 3),
    old log /var/log/mysql.log.3.gz does not exist
    renaming /var/log/mysql.log.2.gz to /var/log/mysql.log.3.gz (rotatecount 7, logstart 1, i 2),
    old log /var/log/mysql.log.2.gz does not exist
    renaming /var/log/mysql.log.1.gz to /var/log/mysql.log.2.gz (rotatecount 7, logstart 1, i 1),
    old log /var/log/mysql.log.1.gz does not exist
    renaming /var/log/mysql.log.0.gz to /var/log/mysql.log.1.gz (rotatecount 7, logstart 1, i 0),
    old log /var/log/mysql.log.0.gz does not exist
    rotating log /var/log/mysql/mysql.log, log->rotateCount is 7
    dateext suffix '-20171023'
    glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
    renaming /var/log/mysql/mysql.log.7.gz to /var/log/mysql/mysql.log.8.gz (rotatecount 7, logstart 1, i 7),
    old log /var/log/mysql/mysql.log.7.gz does not exist
    renaming /var/log/mysql/mysql.log.6.gz to /var/log/mysql/mysql.log.7.gz (rotatecount 7, logstart 1, i 6),
    old log /var/log/mysql/mysql.log.6.gz does not exist
    renaming /var/log/mysql/mysql.log.5.gz to /var/log/mysql/mysql.log.6.gz (rotatecount 7, logstart 1, i 5),
    old log /var/log/mysql/mysql.log.5.gz does not exist
    renaming /var/log/mysql/mysql.log.4.gz to /var/log/mysql/mysql.log.5.gz (rotatecount 7, logstart 1, i 4),
    old log /var/log/mysql/mysql.log.4.gz does not exist
    renaming /var/log/mysql/mysql.log.3.gz to /var/log/mysql/mysql.log.4.gz (rotatecount 7, logstart 1, i 3),
    old log /var/log/mysql/mysql.log.3.gz does not exist
    renaming /var/log/mysql/mysql.log.2.gz to /var/log/mysql/mysql.log.3.gz (rotatecount 7, logstart 1, i 2),
    old log /var/log/mysql/mysql.log.2.gz does not exist
    renaming /var/log/mysql/mysql.log.1.gz to /var/log/mysql/mysql.log.2.gz (rotatecount 7, logstart 1, i 1),
    old log /var/log/mysql/mysql.log.1.gz does not exist
    renaming /var/log/mysql/mysql.log.0.gz to /var/log/mysql/mysql.log.1.gz (rotatecount 7, logstart 1, i 0),
    old log /var/log/mysql/mysql.log.0.gz does not exist
    log /var/log/mysql/mysql.log.8.gz doesn't exist -- won't try to dispose of it
    rotating log /var/log/mysql/mysql-slow.log, log->rotateCount is 7
    dateext suffix '-20171023'
    glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
    renaming /var/log/mysql/mysql-slow.log.7.gz to /var/log/mysql/mysql-slow.log.8.gz (rotatecount 7, logstart 1, i 7),
    old log /var/log/mysql/mysql-slow.log.7.gz does not exist
    renaming /var/log/mysql/mysql-slow.log.6.gz to /var/log/mysql/mysql-slow.log.7.gz (rotatecount 7, logstart 1, i 6),
    old log /var/log/mysql/mysql-slow.log.6.gz does not exist
    renaming /var/log/mysql/mysql-slow.log.5.gz to /var/log/mysql/mysql-slow.log.6.gz (rotatecount 7, logstart 1, i 5),
    old log /var/log/mysql/mysql-slow.log.5.gz does not exist
    renaming /var/log/mysql/mysql-slow.log.4.gz to /var/log/mysql/mysql-slow.log.5.gz (rotatecount 7, logstart 1, i 4),
    old log /var/log/mysql/mysql-slow.log.4.gz does not exist
    renaming /var/log/mysql/mysql-slow.log.3.gz to /var/log/mysql/mysql-slow.log.4.gz (rotatecount 7, logstart 1, i 3),
    old log /var/log/mysql/mysql-slow.log.3.gz does not exist
    renaming /var/log/mysql/mysql-slow.log.2.gz to /var/log/mysql/mysql-slow.log.3.gz (rotatecount 7, logstart 1, i 2),
    old log /var/log/mysql/mysql-slow.log.2.gz does not exist
    renaming /var/log/mysql/mysql-slow.log.1.gz to /var/log/mysql/mysql-slow.log.2.gz (rotatecount 7, logstart 1, i 1),
    old log /var/log/mysql/mysql-slow.log.1.gz does not exist
    renaming /var/log/mysql/mysql-slow.log.0.gz to /var/log/mysql/mysql-slow.log.1.gz (rotatecount 7, logstart 1, i 0),
    old log /var/log/mysql/mysql-slow.log.0.gz does not exist
    log /var/log/mysql/mysql-slow.log.8.gz doesn't exist -- won't try to dispose of it
    rotating log /var/log/mysql/error.log, log->rotateCount is 7
    dateext suffix '-20171023'
    glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
    renaming /var/log/mysql/error.log.7.gz to /var/log/mysql/error.log.8.gz (rotatecount 7, logstart 1, i 7),
    old log /var/log/mysql/error.log.7.gz does not exist
    renaming /var/log/mysql/error.log.6.gz to /var/log/mysql/error.log.7.gz (rotatecount 7, logstart 1, i 6),
    old log /var/log/mysql/error.log.6.gz does not exist
    renaming /var/log/mysql/error.log.5.gz to /var/log/mysql/error.log.6.gz (rotatecount 7, logstart 1, i 5),
    old log /var/log/mysql/error.log.5.gz does not exist
    renaming /var/log/mysql/error.log.4.gz to /var/log/mysql/error.log.5.gz (rotatecount 7, logstart 1, i 4),
    old log /var/log/mysql/error.log.4.gz does not exist
    renaming /var/log/mysql/error.log.3.gz to /var/log/mysql/error.log.4.gz (rotatecount 7, logstart 1, i 3),
    old log /var/log/mysql/error.log.3.gz does not exist
    renaming /var/log/mysql/error.log.2.gz to /var/log/mysql/error.log.3.gz (rotatecount 7, logstart 1, i 2),
    old log /var/log/mysql/error.log.2.gz does not exist
    renaming /var/log/mysql/error.log.1.gz to /var/log/mysql/error.log.2.gz (rotatecount 7, logstart 1, i 1),
    old log /var/log/mysql/error.log.1.gz does not exist
    renaming /var/log/mysql/error.log.0.gz to /var/log/mysql/error.log.1.gz (rotatecount 7, logstart 1, i 0),
    old log /var/log/mysql/error.log.0.gz does not exist
    renaming /var/log/mysql.log to /var/log/mysql.log.1
    creating new /var/log/mysql.log mode = 0640 uid = 112 gid = 4
    renaming /var/log/mysql/mysql.log to /var/log/mysql/mysql.log.1
    creating new /var/log/mysql/mysql.log mode = 0640 uid = 112 gid = 4
    renaming /var/log/mysql/mysql-slow.log to /var/log/mysql/mysql-slow.log.1
    creating new /var/log/mysql/mysql-slow.log mode = 0640 uid = 112 gid = 4
    renaming /var/log/mysql/error.log to /var/log/mysql/error.log.1
    creating new /var/log/mysql/error.log mode = 0640 uid = 112 gid = 4
    running postrotate script
    error: error running shared postrotate script for '/var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/error.log '

  3. #3
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,878
    Hello,

    Postrotate section in /etc/logrotate.d/mysql contains instructions to flush-logs.

    Code:
        postrotate
        # just if mysqld is really running
            if test -x /usr/bin/mysqladmin && \
                /usr/bin/mysqladmin ping &>/dev/null
           then
                /usr/bin/mysqladmin flush-logs
            fi
        endscript
    for this to work you might need to create /root/.my.cnf with details to connect to MySQL server or update instructions to the following view

    Code:
        postrotate
        # just if mysqld is really running
            if test -x /usr/bin/mysqladmin && \
                /usr/bin/mysqladmin --defaults-extra-file=/usr/local/directadmin/conf/my.cnf ping &>/dev/null
           then
                /usr/bin/mysqladmin --defaults-extra-file=/usr/local/directadmin/conf/my.cnf flush-logs
            fi
        endscript

    If your file differs let us know.

  4. #4
    Join Date
    Jun 2017
    Location
    ZS
    Posts
    50
    in /etc/logrotate.d/mysql-server
    # - I put everything in one block and added sharedscripts, so that mysql gets
    # flush-logs'd only once.
    # Else the binary logs would automatically increase by n times every day.
    /var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/$
    daily
    rotate 7
    missingok
    create 640 mysql adm
    compress
    sharedscripts
    postrotate
    test -x /usr/bin/mysqladmin || exit 0
    # If this fails, check debian.conf!
    MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql.moved/d$
    if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then
    # Really no mysqld or rather a missing debian-sys-maint user?
    # If this occurs and is not a error please report a bug.
    #if ps cax | grep -q mysqld; then
    if killall -q -s0 -umysql mysqld; then
    exit 1
    fi
    else
    $MYADMIN flush-logs
    fi
    endscript
    }

  5. #5
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,878
    Check the variant I've posted above.. it shows a correct path for my.cnf on Directadmin servers.

  6. #6
    Join Date
    Jun 2017
    Location
    ZS
    Posts
    50
    Quote Originally Posted by zEitEr View Post
    Check the variant I've posted above.. it shows a correct path for my.cnf on Directadmin servers.
    ok, I have change this conf. file and replace this code. Now I have only error with
    /etc/cron.daily/logrotate:
    error: mysql-server-backup:4 duplicate log entry for /var/log/mysql.log

  7. #7
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    11,878
    Remove the duplicated records then or files.

Posting Permissions

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