пятница, 11 ноября 2022 г.

Linux logrotate jira logs

 Jira has its own log rotate

However, it doesn't delete old files.

It can be done with crontab though.

#### remove old jira log files longer 180 days

30 2 * * * /usr/bin/find /opt/atlassian/servicedesk/logs/ -maxdepth 1 -type f -mtime +180 -exec rm -rf {} \;

45 2 * * * /usr/bin/find /opt/atlassian/servicedesk/logs/ -maxdepth 1 -type f -mtime +6 -exec gzip -q {} \;



суббота, 26 февраля 2022 г.

Linux logrotate twice per day

Before:

/etc/logrotate.d/logs

/mnt/shared/project/var/log/*.log 

{
  su www-project www-data
  rotate 30
  daily
  missingok
  compress
  notifempty
  copytruncate
  dateext

}

After:

1) create a separate additional logrotate conf file /etc/logrotate.d/logs_erp with content below (increased twice rotate 30 -> 60 and plus delaycompress):

/etc/logrotate.d/logs_erp
/mnt/shared/project/var/log/erp.log 
{
  su www-project www-data
  rotate 60
  daily
  missingok
  compress
  delaycompress
  notifempty
  copytruncate
  dateext
}
2) modify current logrotate conf file /etc/logrotate.d/logs with excluding first 'erp' characters from wildcard:
/mnt/shared/project/var/log/[!e][!r][!p]*.log 
{
  su www-project www-data
  rotate 30
  daily
  missingok
  compress
  notifempty
  copytruncate
  dateext
}
3) run logrotate conf file /etc/logrotate.d/logs_erp by cron additionally at 18.25
under root account
25 18 * * * logrotate -f /etc/logrotate.d/logs_erp

понедельник, 3 января 2022 г.

четверг, 30 декабря 2021 г.

Magento 2 How to throw report error page (500 error) for testing purpose

 The goal is to get a report page for testing purpose 

So, we have to break magento somehow.

The fast way is:

1. pub/media is symlink to media folder

2. rename real media folder to media.bk

3. open PLP and enjoy the error

var/report will be:

Directory \"\/mnt\/data\/www\/project\/releases\/pub\/media\" cannot be created Warning!mkdir(): File exists" ...

четверг, 16 сентября 2021 г.

Linux Bash check disk space

df --output=pcent / | tail -n +2 | tr -cd '0-9\n'

output available percent without header and symbol '%' - only number

#!/bin/bash

for mnt in / /var/log /var/www /mnt/shared; do

  chk_avail=`df --output=pcent $mnt | tail -n +2 | tr -cd '0-9\n'`

  flg=`echo $(( 100 - $chk_avail ))`

  if [ $flg -lt 15 ]; then

    echo 'Dataserver lack of free space, only '$flg' percent available in '$mnt' partition' | mail -s 'Dataserver lack of free space' alerts@gmail.com

  fi

done



пятница, 23 апреля 2021 г.

Magento 2 Multistore one domain

domain.com/store1

domain.com/store2

  1. Admin Panel: Stores/Settings/Stores (table store for checking code for MAGE_RUN_CODE)
    website: base, store: store1_code, store view: store1
    website: base, store: store2_code, store view: store2
  2. Admin Panel: Configuration/Web/URL Options/Add Store Code to Urls - Yes
  3. NGINX: 

    .php

        fastcgi_param  MAGE_RUN_TYPE    $MAGE_RUN_TYPE;

        fastcgi_param  MAGE_RUN_CODE    $MAGE_RUN_CODE;

    http

    map $request_uri $MAGE_RUN_CODE {

        ~^/store1 store1;

        ~^/store2 store2;

    }

    server
        set $MAGE_RUN_TYPE store;

воскресенье, 14 марта 2021 г.