Setting rules: 1. Each user can store up to 20 mb of files, and can create up to 200 files. 2. warn users when creating files larger than 100 mb and more than files. 3. Because some users have exceeded the above restrictions, we must first notify the user via email to process unnecessary files as soon as possible. 2. Due to the sudden occurrence of the incident, in order to avoid strong user feedback, we should first give each user a 7-day period so that the user has the opportunity to back up files. However, after 7 days, the deadline will be automatically changed to 2 days. Solution: 1. Set the disk quota for each user account. 2. Send a notification to all users who have exceeded the limit. 3. The period is automatically changed to 2 days after 7 days. Step: 1. Set the disk quota for each user account. Use edquota with the-p Parameter www.2cto.com to manually configure a user's disk quota using edquota, set it as a template, call it to other users, and run the following command: dequota [-u |-g]-p tempname names where TEMONAME is the name of the template user, and NAMES is the name of the user to be called. For example, dequota-p jacky allen bill cherry uses jacky as the template to call jacky's disk quota settings to allen bill cherry and other users. Another method is to use the setquota tool. With the Shell loop technique, set the disk quota for each user. For user in jacky allen bill cherry; dosetquota $ {user} 10240 20480 100 200/datadone requires a large number of usernames. Here, we can use awk to extract common users whose UID is greater than or equal to 500. Awk-F: '{if ($3> = 500) print $1}'/etc/passwd and then hand over the above results to edquota for use. Www.2cto.com awk-F: '{if ($3> = 500) print $1} '/etc/passwd | xargs edquota-p jacky uses setquota as the for user in (awk-F:' {if ($3> = 500) print $1} '/etc/passwd); dosetquota $ {user} 10240 20480 100 200/datadone
2. Send a notification to all users who have exceeded the limit. We can send emails via warnquota to users who exceed the disk quota. However, warnquota uses/etc/warnquota. conf content generates an English email. Besides, we want to customize the email, although we can modify/etc/warnquota. conf, but only one email is required. It will not be sent in the future. After sending the email, you must restore it back. Therefore, we can generate a file in the same format as/etc/warnquota. conf. For example, in my ~ /Warnquota. conf MAIL_CMD = "/usr/sbin/sendmail-t" FROM = www.2cto.com SUBJECT = Note: you have exceeded the disk quota limit CC_TO = "root @ localhost" SUPPORT = "me@myhost.com" PHONE = "15 *********" MESSAGE = Hello, your disk quota has exceeded the alert value. | Delete unnecessary files. SIGNATURE = me@myhost.com and then execute the following command to make warnquota temporarily use our configuration file (~ /Warnquota. conf) sends all emails. [Root @ guo ~] # Warnquota-c ~ /Warnquota. conf 3. The period is automatically changed to 2 days after 7 days (the date is automatically modified ). You can use two methods to set the system duration of the disk quota. The first method is to run the preceding command through edquota: edquota-t, edquota will enable the editing software for the $ EDITOR Environment variable definition, set the quota period for the disk. Then, use at for scheduled service. At 0 am + 7days, change the term to 2 days. All the required tasks are completed here.
Author junjieguo