Creating a file on boot up

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 ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-28-2004
srinivas
 
Posts: n/a
Default Creating a file on boot up

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.
Reply With Quote
  #2 (permalink)  
Old 05-28-2004
Lew Pitcher
 
Posts: n/a
Default Re: Creating a file on boot up

-----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-----
Reply With Quote
  #3 (permalink)  
Old 05-29-2004
Clive Dove
 
Posts: n/a
Default Re: Creating a file on boot up

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:30 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0