What's with my shell script?

LuckyTaxi

Diamond Member
Dec 24, 2000
6,044
23
81
Ok ... i wrote a shell script that tar and then gzip a whole bunch of files and then it sends the copy over to our NAS device, which then deletes it off the server. Well, lately these files are getting bigger and bigger, but they are stored in a partition that has plenty of free space.

So anyways, the cron job starts at 3 in the morning. I come in the morning and what do you know. the root partition [/] runs out of room. The files I'm trying to "zip" up and copy over are located in the /var partition. Why is it being zipped and temporarily placed in the / partition? I didnt notice this until the process would hang since it ran out of room on the / partition. How can I do the whole process in the /var partition so I dont encounter this?

Is it because of the following?

1 - cron job running as root
or
2 - /tmp is located in the / partition

BTW ... / partition is about 3 GB. During normal times it has about 100 MB in used space.
 

LuckyTaxi

Diamond Member
Dec 24, 2000
6,044
23
81
not sure about #2. only because a portion of the file (whatever it could zip up) is left in the /root directory and not the /tmp directory. so tonight i set it to run as a normal user and see if the it ends up in /home/username if it does stall again
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Use absolute paths in the script.

tar -cf /var/blah/files.tar /var/blah/files Instead of tar -cf files.tar /var/blah/files

(GUESS ;))
 

LuckyTaxi

Diamond Member
Dec 24, 2000
6,044
23
81
Originally posted by: n0cmonkey
Use absolute paths in the script.

tar -cf /var/blah/files.tar /var/blah/files Instead of tar -cf files.tar /var/blah/files

(GUESS ;))

oh damn ... good one ... let me go change now

 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: lilcam
Originally posted by: n0cmonkey
Use absolute paths in the script.

tar -cf /var/blah/files.tar /var/blah/files Instead of tar -cf files.tar /var/blah/files

(GUESS ;))

oh damn ... good one ... let me go change now

I was thinking how hard it is to troubleshoot a script without being able to see it, and somehow that made me think of that "tip" :p
 

LuckyTaxi

Diamond Member
Dec 24, 2000
6,044
23
81
Originally posted by: n0cmonkey
Originally posted by: lilcam
Originally posted by: n0cmonkey
Use absolute paths in the script.

tar -cf /var/blah/files.tar /var/blah/files Instead of tar -cf files.tar /var/blah/files

(GUESS ;))

oh damn ... good one ... let me go change now

I was thinking how hard it is to troubleshoot a script without being able to see it, and somehow that made me think of that "tip" :p

would've helped if i posted the script ;)
well, i think that will fix it. We'll find out in a couple of hours