Results 1 to 4 of 4

Thread: Cron job

  1. #1
    Join Date
    Jun 2017
    Posts
    30

    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
    Posts
    30
    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,157
    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.
    With regards, Alex.

    Professional Server Management for web hosting companies and individuals
    Hourly Support, Disaster Recovery, Server Hardening, Monthly Subscription
    Directadmin installation and optimization

    Click here if you need a Linux Admin

  4. #4
    Join Date
    Jun 2017
    Posts
    30
    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
    }

Posting Permissions

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