الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

file-size-driven cron job

مغلق
بدأه amin1982 في 31 يوليو 2007 · 3 رد · 846 مشاهدة · في نظام تشغيل Unix & Linux
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

i have a rotating log files in solaris server

assume that i have the following situation:

the log files are 10 files each with maximum size of 2MB , when the first log is full the second will start getting data and so on

how can i create a cron job that do the following:

when a log file reaches the max size , the cron job sends it to another directory

شكرا

#2

وعليكم السلام

you can create shell script, then ,create function that calculate the file size each time you need, and you must make this function inside loop,this loop change log file name each time the size of log file increase than 2MB.

System Engineer

Red Hat Certified Engineer

Red Hat Certificate Number

805010381752078

#3
#!/bin/bash
. /etc/profile
#crontab will run this script

#its main function is archiving the ErrorLog.txt file
Dir=/Logs
ArcDir=/arclog
y=$(date +%Y)
m=$(date +%m)
d=$(date +%Oe)
H=$(date +%H)
M=$(date +%M)

echo day is $d
echo month is $m
echo year is $y
d=$[$d+0]
m=$[$m+0]
date=$y$m$d$H$M
cd $ArcDir
mkdir $date
cd $Dir
echo $Dir
echo /$date
echo $ArcDir
echo $ArcDir/$date
mv $Dir/ErrorLog.txt $ArcDir/$date
#rm  $Dir/ErrorLog.txt

I use this script to Archive some log files, you need to change it to count the size before moving the log file.

#4

شكرا برق و jamal

هل تعلمان عن طريقة في الوندوز لقراءة ملف على سرفر اخر ؟؟؟

هذا الموضوع مغلق.

مواضيع مشابهة