-1

How can I get separate assigned path disk usage by crontab job to do it? For example, I would like to find out the path as list as below ex:

/var/example/attachments/ver003/112/24

/var/example/attachments/ver003/10/13/12

/var/example/attachments/ver003/119/12

How can I use du -sh to got their disk usage by crontab or sh file to output the result? output: path1:10GB

path2:20MB

path3:850MB
1
  • Could you try to reformulate? I'm not sure what you're asking for. Something like look for partitions matching a pattern and check for space used? Are those arbitrary folders, or mount points for network or block devices? What are you trying to do? – SYN Jul 16 '20 at 15:21
1

Try this:

for i in /var/example/attachments/ver003/112/24 /var/example/attachments/ver003/10/13/12 /var/example/attachments/ver003/119/12; do 
    du $i -sh | awk -v p=$i '{print p,":",$1;}'
done
3
  • Thanks a lot, my code is as listed as below: or i in /var/atlassian/application-data/confluence/attachments/ver003/90/26 /var/atlassian/application-data/confluence/attachments/98/26; do (enter next) du &i -sh | awk -v p=$i '{print p,":",$1;}' (enter next) done But when I run , it show message : line 6: syntax error: unexpected end of file – show0116 Jul 18 '20 at 13:42
  • Well, this is strange. I gave you three lines of code, and you say the error is in line 6. However, in your post you are missing letter f at the beginning. It should say for and not or. Then you have &i instead of $i in the second line. – nobody Jul 19 '20 at 20:21
  • thanks a lot. It's ok. But can I give each path a name, not real path? For example path1 120MB, path2 1GB, path3, 251MB. – show0116 Aug 6 '20 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.