Is there a right and wrong way to do this?

Paul Gear paul at libertysys.com.au
Thu May 15 08:59:54 BST 2008


David Ryder wrote:
> Hi,
> I'm David - been on the list a awhile and read a lot but not answered or
> been able to help a lot - yes, still learning ... after some time!

Good to have you with us, David!  :-)

> Anyway, I would like to ask, firstly, I have a cron job file that I have
> added to /etc/cron.d/
> It uses files I have in my home folder, but which are symlinked
> in /usr/local/bin/.
> Is there a 'good, bad or ugly' reason why I shouldn't symlink my cron
> file also? i.e. a symlink in /etc/cron.d/
> to /home/david/my-cron-jobs/filename ?
> It would make changes to the cron jobs very much easier. Otherwise I
> have to either place a copy there or run another cron job to keep my
> cron files up to date (the originals are in my home folder).

I often symlink a number of related files from /etc into another similar
tree.  In this case, if you already have files in /usr/local/bin, i
would symlink the file in question into /usr/local/etc/cron.d/.  The
advantage of this is that /usr/local will never be messed with by the OS
[1].

> Secondly - can I replace via copy (cp) a file while the target file is
> open? If so, I can't find the switch to do it.

There's no switch - you just copy the file.  In most cases, it will just
overwrite the file, although if another process has locked it, cp may be
smart enough to fail.  In that case, the usual way to replace it is to
rename it to something else, and copy the new file in with the original
name.

Keep in mind with many of these techniques may appear to work, but if
running applications leave the file open, they will continue to work on
the old data, which may not even be visible in the filesystem (e.g. if
you've deleted the file).  The Unix file open/read/write paradigm is
simple and elegant, but takes a bit of getting used to.

Paul

[1] http://www.pathname.com/fhs/pub/fhs-2.3.html#USRLOCALLOCALHIERARCHY
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4633 bytes
Desc: S/MIME Cryptographic Signature
Url : https://lists.ubuntu.com/archives/ubuntu-au/attachments/20080515/9b36e478/attachment.bin 


More information about the ubuntu-au mailing list