Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Security issue and temp files Post 302358200 by Corona688 on Thursday 1st of October 2009 04:16:42 PM
Old 10-01-2009
Quote:
Originally Posted by mojoman
On my system I created a symbolic link called temp1 pointing to /etc/passwd and then I used touch to create a file called temp1 to see what would happen. But when I tried to create the file with touch, most likely because the symbolic link called temp 1 was already there.
It's safe enough to touch /etc/passwd, but imagine what would happen if you'd overwrote it instead.

Using that predictable a name for your temp files has another problem though: What if you want to run two instances of your script at once? I usually do something like
Code:
TMPFILE="/tmp/$$-myprogram"

so each process has a different tempfile. That's only a half step away from using mktemp...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Tidying up temp files on exit of script

Hi I believe there is a method to remove all temporary files when a KSH script terminates (either expectedly or unexpectedly). I think is some sort of subroutine you can create that runs when the script exits. Can anyone help me with this please? Many thanks Helen :confused: (2 Replies)
Discussion started by: Bab00shka
2 Replies

2. Shell Programming and Scripting

Script to Delete temp files and check file system

Hi all, new to the threads as well as Unix/Linux. I need to create a script that will delete any temporary files as well as check the files on the system for errors or corruption. This is what I have so far and I'm sure that I'm missing things or have the wrong commands. I'm not sure where to go... (3 Replies)
Discussion started by: Bwood1377
3 Replies

3. Shell Programming and Scripting

Joining 3 AWK scripts to avoid use "temp" files

Hi everyone, Looking for a suggestion to improve the below script in which I´ve been working. The thing is I have 3 separated AWK scripts that I need to apply over the inputfile, and for scripts (2) and (3) I have to use a "temp" file as their inputfile (inputfile_temp and inputfile_temp1... (2 Replies)
Discussion started by: cgkmal
2 Replies

4. UNIX for Dummies Questions & Answers

Temp mysql files jamming CPU resources

Hello Friends I am currently facing high CPU usage problem which is making my site extremely slow. Currently I am using a 8GB RAM with 8 cores but, the creation of temporary files is eating away a lot of the CPU resource making the site very slow. The normal CPU load average remains below 2-3... (5 Replies)
Discussion started by: egully
5 Replies

5. Shell Programming and Scripting

temp files

Hi there, As a regular unix user I am forever programming on the command line or writing scripts so that I first write a load of data to a file to read from. In the end I am always left with a bundle of .txt, .tmp which is what I usually call them. As a basic programmmer I was wondering is... (6 Replies)
Discussion started by: cyberfrog
6 Replies

6. Shell Programming and Scripting

Script to temp create files more than inode limit

HI, I am from testing background. I have a scenario of a file generation, through cronjob, on a defined path. After I fill the data as 100 % utilized, my application is generating an empty file on the defined path. # df -kh Filesystem Size Used Avail Use% Mounted on... (3 Replies)
Discussion started by: atulbassi83
3 Replies

7. OS X (Apple)

Safari Temp Internet Files Location

I'm looking for help with finding where plugin data and other page resources are stored on the hard disk in safari 6.0. With the new update, the activity window has been merged into the develop menu under "show page resources" and one cannot access them directly. I tried running opensnoop to see... (3 Replies)
Discussion started by: sakurashinken
3 Replies

8. Shell Programming and Scripting

Backup shell script created temp files .

Hi, I've a script which creates a temp flat file for storing all business dates received on a single day from diff control files sent by source system on that day. e.g on 12th april I receive txns for business day 8,9,10,11 april. I capture this business day and append to a flat file from... (1 Reply)
Discussion started by: manojg9
1 Replies

9. Shell Programming and Scripting

RMTF (ReMove Temp Files)

Heyas As some applications (sed,grep,vi, etc) create some tempfiles, i'd changed a script to this: (sadly i cant find the original post (code) anymore (which just removed 2 'diffrent kinds'), just similar ones - forgot that as i was new to all this) :) ~ $ cat $(which rmtf) #!/bin/sh #... (1 Reply)
Discussion started by: sea
1 Replies

10. Shell Programming and Scripting

Removing large number of temp files

Hi All, I am having a situation now to delete a huge number of temp files created during run times approx. 16700+ files. We have never imagined that we will get this this much big list of files during run time. It worked fine for lesser no of files in the list. But when list is huge we are... (7 Replies)
Discussion started by: mad man
7 Replies
TOUCH(1)						    BSD General Commands Manual 						  TOUCH(1)

NAME
touch -- change file access and modification times SYNOPSIS
touch [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ... DESCRIPTION
The touch utility sets the modification and access times of files to the current time of day. If the file doesn't exist, it is created with default permissions. The following options are available: -a Change the access time of the file. The modification time of the file is not changed unless the -m flag is also specified. -c Do not create the file if it does not exist. The touch utility does not treat this as an error. No error messages are displayed and the exit value is not affected. -f This flag has no effect; it is accepted for compatibility reasons. -h If file is a symbolic link, access and/or modification time of the link is changed. This option implies -c. -m Change the modification time of the file. The access time of the file is not changed unless the -a flag is also specified. -r Use the access and modifications times from the specified file instead of the current time of day. -t Change the access and modification times to the specified time. The argument should be in the form ``[[CC]YY]MMDDhhmm[.SS]'' where each pair of letters represents the following: CC The first two digits of the year (the century). YY The second two digits of the year. If ``YY'' is specified, but ``CC'' is not, a value for ``YY'' between 69 and 99 results in a ``CC'' value of 19. Otherwise, a ``CC'' value of 20 is used. MM The month of the year, from 1 to 12. DD The day of the month, from 1 to 31. hh The hour of the day, from 0 to 23. mm The minute of the hour, from 0 to 59. SS The second of the minute, from 0 to 61. If the ``CC'' and ``YY'' letter pairs are not specified, the values default to the current year. If the ``SS'' letter pair is not specified, the value defaults to 0. The touch utility exits 0 on success, and >0 if an error occurs. COMPATIBILITY
The obsolescent form of touch, where a time format is specified as the first argument, is supported. When no -r or -t option is specified, there are at least two arguments, and the first argument is a string of digits either eight or ten characters in length, the first argument is interpreted as a time specification of the form ``MMDDhhmm[YY]''. The ``MM'', ``DD'', ``hh'' and ``mm'' letter pairs are treated as their counterparts specified to the -t option. If the ``YY'' letter pair is in the range 69 to 99, the year is set to 1969 to 1999, otherwise, the year is set in the 21st century. SEE ALSO
utimes(2) STANDARDS
The touch utility is expected to be a superset of the IEEE Std 1003.2 (``POSIX.2'') specification. HISTORY
A touch utility appeared in Version 7 AT&T UNIX. BUGS
A symbolic link can't be a reference file of access and/or modification time. BSD
February 22, 2011 BSD
All times are GMT -4. The time now is 11:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy