powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Unix-системы [игнор отключен] [закрыт для гостей] / получение отчетов sarg
13 сообщений из 13, страница 1 из 1
получение отчетов sarg
    #33573643
Фотография Green2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Такая ситуация, я настраиваю sarg, Apache настроен.
Надо еженедельно запускать командную строку типа:
sarg -d 4/2/2006-11/2/2006
и ежемесячно запускать:
sarg -d 1/2/2006-28/2/2006

это надо прописать в папке /etc/cron.weekly и /etc/cron.monthly
какой то скрипт... sh или bath
Как написать скрипт, который сформирует такую строку,
1) получит предыдущую неделю до сегодняшнего дня
2) Получит предыдущий месяц
и выдаст в командной строке?
--



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573733
nik2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Green2
Такая ситуация, я настраиваю sarg, Apache настроен.
Надо еженедельно запускать командную строку типа:
sarg -d 4/2/2006-11/2/2006
и ежемесячно запускать:
sarg -d 1/2/2006-28/2/2006

это надо прописать в папке /etc/cron.weekly и /etc/cron.monthly
какой то скрипт... sh или bath
Как написать скрипт, который сформирует такую строку,
1) получит предыдущую неделю до сегодняшнего дня
2) Получит предыдущий месяц
и выдаст в командной строке?


man date
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573864
Фотография Green2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: plaintext
date +%d/%m/ 20 %y 
это получить текущую дату, как её передать в другую программу?
--



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573909
Фотография lissyara
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
я так делаю:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
# достаём день, год, и старый месяц
day=`date '+%d'`
year=`date '+%Y'`
old_month=`date -v-1m '+%m'`
# Если первое число месяца, и предыдущий месяц
# был  12  - то вычисляем старый год
# если первое число выполняем содержимое:
if [ ${day} =  01  ]
then
        if [ ${old_month} =  12  ]
            then
                old_year=`date -v-1Y '+%Y'`
            else
                old_year=${year}
        fi
# считаем SARG`ом статистику по http
#################  SARG #########################
/usr/local/bin/sarg -l /var/old_log/${old_year}/${old_month}/squid.log



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573920
g613
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Green2
Код: plaintext
date +%d/%m/ 20 %y 
это получить текущую дату, как её передать в другую программу?


Код: plaintext
1.
echo "Esterday: "`date -d '-1 day' +%d/%m/ 20 %y`

про то как передать - зависит от того как их хочет получить `другая` программа.
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573931
Фотография Green2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
как выбрать в bash:
1) вывод программы data ввести в переменную
2) как получить дату на неделю ранее текущей? На месяц ранее?

--



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573954
Фотография Green2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
2 lissyara
спасибо, это все что надо
--



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573958
Фотография lissyara
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Забавно :)
мне подобного примера хватило чтобы логику понять. 2 минуты на экспериметы и
всё...

Код: plaintext
old_month=`date -v-1m '+%m'`


Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33573970
Фотография lissyara
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
не успел

P.S. Ты ж на перле вроде писал раньше?
Так и напиши на перле.
Никто не заставляет писать на другом.


Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33574001
Фотография Green2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
пожалуй напишу на perl
только я думал что bash проще
Кстати, в команде date я не нашел ключа -v
--



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33574030
Фотография APM
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Конвейер вроде называется...

date +%d/%m/*20*%y | mail root
Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33574033
Фотография lissyara
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
линух...
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
     -v      Adjust (i.e., take the current date and display the result 
of the
             adjustment; not actually set the date) the second, minute, 
hour,
             month day, week day, month or year according to val.  If val is
             preceded with a plus or minus sign, the date is adjusted 
forwards
             or backwards according to the remaining string, otherwise the
             relevant part of the date is set.  The date can be adjusted as
             many times as required using these flags.  Flags are processed 
in
             the order given.

             When setting values (rather than adjusting them), seconds are 
in
             the range  0 - 59 , minutes are in the range  0 - 59 , hours are in the
             range  0 - 23 , month days are in the range  1 - 31 , week days are in
             the range  0 - 6  (Sun-Sat), months are in the range  1 - 12  (Jan-Dec)
             and years are in the range  80 - 38  or  1980 - 2038 .

             If val is numeric, one of either y, m, w, d, H, M or S must be
             used to specify which part of the date is to be adjusted.

             The week day or month may be specified using a name rather than 
a
             number.  If a name is used with the plus (or minus) sign, the
             date will be put forwards (or backwards) to the next (previous)
             date that matches the given week day or month.  This will not
             adjust the date, if the given week day or month is the same as
             the current one.

             When a date is adjusted to a specific value or in units greater
             than hours, daylight savings time considerations are ignored.
             Adjustments in units of hours or less honor daylight saving 
time.
             So, assuming the current date is March  26 ,  0 : 30  and that the 
DST
             adjustment means that the clock goes forward at  01 : 00  to  02 : 00 ,
             using -v +1H will adjust the date to March  26 ,  2 : 30 .  Likewise,
             if the date is October  29 ,  0 : 30  and the DST adjustment means 
that
             the clock goes back at  02 : 00  to  01 : 00 , using -v +3H will be 
nec-
             essary to reach October  29 ,  2 : 30 .

             When the date is adjusted to a specific value that doesn't 
actu-
             ally exist (for example March  26 ,  1 : 30  BST  2000  in the
             Europe/London timezone), the date will be silently adjusted 
for-
             wards in units of one hour until it reaches a valid time.  When
             the date is adjusted to a specific value that occurs twice (for
             example October  29 ,  1 : 30   2000 ), the resulting timezone will be
             set so that the date matches the earlier of the two times.

             Adjusting the date by months is inherently ambiguous because a
             month is a unit of variable length depending on the current 
date.
             This kind of date adjustment is applied in the most intuitive
             way.  First of all, date tries to preserve the day of the 
month.
             If it is impossible because the target month is shorter than 
the
             present one, the last day of the target month will be the 
result.
             For example, using -v +1m on May  31  will adjust the date to 
June
              30 , while using the same option on January  30  will result in 
the
             date adjusted to the last day of February.  This approach is 
also
             believed to make the most sense for shell scripting.  Neverthe-
             less, be aware that going forth and back by the same number of
             months may take you to a different date.

             Refer to the examples below for further details.



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
получение отчетов sarg
    #33673870
Фотография Green2
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: plaintext
1.
2.
3.
4.
#!/bin/bash
exec /usr/bin/sarg \
-o /var/www/sarg/daily \
-d "$(date --date "1 day ago" +%d/%m/%Y)"

Код: plaintext
1.
2.
3.
4.
#!/bin/bash
exec /usr/bin/sarg \
-o /var/www/sarg/weekly \
-d "$(date --date "1 week ago" +%d/%m/%Y)-$(date --date "1 day ago" +%d/%m/%Y)"


Код: plaintext
1.
2.
3.
4.
5.
6.
7.
#!/bin/bash

exec /usr/bin/sarg \

-o /var/www/sarg/monthly \

-d "$(date --date "1 month ago" +%d/%m/%Y)-$(date --date "1 day ago" +%d/%m/%Y)"
--



Posted via ActualForum NNTP Server 1.3
...
Рейтинг: 0 / 0
13 сообщений из 13, страница 1 из 1
Форумы / Unix-системы [игнор отключен] [закрыт для гостей] / получение отчетов sarg
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]