This is a discussion on Creating a file on boot up within the Linux Administration forums, part of the Linux Forums category; Hello groups, I am writing am application in Linux 8.0 in which i need to create an empty file ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello groups,
I am writing am application in Linux 8.0 in which i need to create an empty file or just touch it on bootup which i will use it later in my application to check if the file exists. Can you tell me how to create a file on boot up and in which boot file should i make changes in order create an empty file. Thanks for your previous replies. waiting for reply .................. bye. |
|
|||
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 srinivas wrote: > Hello groups, > I am writing am application in Linux 8.0 There is no such thing as "Linux 8.0". Linux (which is the kernel of an operating system) currently is at level 2.6 (2.6.7, IIRC). You probably don't mean that your kernel is at 8.0 level, but that your /distribution/ is at 8.0 level. This may seem pedantic, but it is important. If we are to help you, we need to know /which/ distribution you use. > in which i need to > create an empty file or just touch it on bootup which i will use it > later in my application to check if the file exists. No problem. That is doable. > Can you tell me > how to create a file on boot up and in which boot file should i make > changes in order create an empty file. The exact manner depends on your distribution. One method would be to include the statement /bin/touch /path/to/my/file in your /etc/rc.d/rc.local file (or the equivalent for your distribution). Going one step back (and a bit more reliable), you could add a line in your /etc/inittab to touch the file at startup. Be careful when you select the name, runlevels and action for the entry, though. It is fairly easy for someone who doesn't know what they are doing to foul up their inittab enough to cause major problems in booting or running their system. > Thanks for your previous replies. > waiting for reply .................. > bye. - -- Lew Pitcher, IT Consultant, Enterprise Application Architecture Enterprise Technology Solutions, TD Bank Financial Group (Opinions expressed here are my own, not my employer's) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) iD8DBQFAt4kkagVFX4UWr64RAspKAJ9NaoZE53DgqH3R3h8w/hBf49er8ACfULxP uDCTrMTwC2iRrG6fDfzrvjE= =AZWv -----END PGP SIGNATURE----- |
|
|||
|
Lew Pitcher wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > srinivas wrote: > >> Hello groups, >> I am writing am application in Linux 8.0 > > There is no such thing as "Linux 8.0". Linux (which is the kernel of > an operating system) currently is at level 2.6 (2.6.7, IIRC). You > probably don't mean that your kernel is at 8.0 level, but that your > /distribution/ is at 8.0 level. > > This may seem pedantic, but it is important. If we are to help you, we > need to know /which/ distribution you use. > >> in which i need to >> create an empty file or just touch it on bootup which i will use it >> later in my application to check if the file exists. > > No problem. That is doable. > >> Can you tell me >> how to create a file on boot up and in which boot file should i make >> changes in order create an empty file. > > The exact manner depends on your distribution. One method would be to > include the statement > /bin/touch /path/to/my/file > in your /etc/rc.d/rc.local file (or the equivalent for your > distribution). > > Going one step back (and a bit more reliable), you could add a line in > your /etc/inittab to touch the file at startup. Be careful when you > select the name, runlevels and action for the entry, though. It is > fairly easy for someone who doesn't know what they are doing to foul > up their inittab enough to cause major problems in booting or running > their system. > > > >> Thanks for your previous replies. >> waiting for reply .................. >> bye. > > > - -- > > Lew Pitcher, IT Consultant, Enterprise Application Architecture > Enterprise Technology Solutions, TD Bank Financial Group > > (Opinions expressed here are my own, not my employer's) > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.4 (MingW32) > > iD8DBQFAt4kkagVFX4UWr64RAspKAJ9NaoZE53DgqH3R3h8w/hBf49er8ACfULxP > uDCTrMTwC2iRrG6fDfzrvjE= > =AZWv > -----END PGP SIGNATURE----- If the file exists, touch will not empty the file. To create an empty file, could this command be used instead? cp /dev/null /path/to/my/file -f This should replace the file with a new one if it exists or make the file if it does not exist. Clive |