Re: Create log file from script code..



Bit Twister <BitTwister@xxxxxxxxxxxxxxxx> writes:

On Thu, 30 Mar 2006 23:10:39 +0200, Geir Holmavatn wrote:
I have managed to create a few scripts which are started from crontab.
However I would like a verification that they actually have been executed.

How do I include in my bash script code to append a line like "MyScript was
run at <current date / time>" to the text file 'cronjobs.log' (and that
cronjobs.log is created if it doesn't exist)...

lots of code examples in /etc/init.d

echo "MyScript started $(date) " >> /tmp/cronjobs.log

This is the simplest solution, but be a bit careful. What happens
if two or more scripts want to update the file at the same time?
Maybe a good question, which the OP has to decide, if it is worth
to worry about. (most possibly not, but it is good to be aware of it.)

For extra points, read
! bash script introduction documentation
http://tldp.org/LDP/intro-linux/html/index.html

! bash script advanced documentation
http://tldp.org/LDP/abs/html/index.html

Agree.

Vilmos
.



Relevant Pages

  • Re: Create log file from script code..
    ... How do I include in my bash script code to append a line like "MyScript was ... bash script introduction documentation ...
    (comp.os.linux.misc)
  • Re: New user from WinXP to Ubuntu 5.10
    ... > Wanna know the following: ... http://livinginternet.com/u/ua.htm <--- Advanced Usenet Usage ... bash script introduction documentation ...
    (comp.os.linux.setup)
  • Re: Days to Month file
    ... bash script introduction documentation ... with a 24 hour test set of files and at least 2 files of YYYYMMDD*txt ...
    (comp.unix.programmer)
  • Re: Days to Month file
    ... > Then the following should help but not all commands may work in your shell. ... bash script introduction documentation ...
    (comp.unix.programmer)
  • Re: guessnet: controlling two interfaces
    ... bash script introduction documentation ... I would like to be able to use /etc/init.d/networking restart when I change my connection while runtime. ... I've seen solutions, where different interface-files are copied to /etc/network/interfaces, on bootup, but that would only work on bootup. ...
    (alt.linux)