Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I have a script called teiid.sh set to run daily by a cron job. The scripts purpose is to initialize the startup of teiid.

How would I make a call to test to see the if teiid.sh is working properly with cron, and not just performing endless actions or no action at all?

Example:

@daily * * * * /etc/init.d/teiid.sh jeff@****.edu

Would chkconfig --add /etc/init.d/teiid.sh help with anything at all?

share|improve this question
    
If your script is called script.sh why do you have /etc/init.d/teiid.sh in your crontab? –  Bryan Garza Mar 27 '12 at 20:44
    
sorry I updated it, I was using it for script.sh for explanation purposes. The actual script is teiid.sh –  Jeff Mar 27 '12 at 20:47
    
What are you actually trying to do: have teiid.sh run after you boot the computer (seems probable) or make it run every day at midnight (this is what your cronjob would actually do)? –  rozcietrzewiacz Mar 27 '12 at 22:54
    
To clarify: I asked the above question mainly because /etc/init.d is not the place to put your daily cron jobs, but where system startup scripts reside. System-wide scripts that should be run daily by cron live under /etc/cron.daily. –  rozcietrzewiacz Mar 27 '12 at 23:00

2 Answers 2

up vote 2 down vote accepted

you can do 2 things..

  1. check /var/log/cron to check if it's being executed
  2. add > /tmp/log 2>&1 to the end of the cron entry. then cat /tmp/log to check if the output is correct.
share|improve this answer
    
Thank you, this is exactly what I was looking for. –  Jeff Mar 28 '12 at 13:15

Making a call to the script to test if it is working properly?
When you wrote it did you test it? Running it with cron would be no different.

Other possibilities - output of your script to a file - trace what your script is doing by adding -x to the "shebang" #!/bin/bash -x or put set x on the next line after

This will provide the trace output. Either way you need to be able to see this information. And if you are not there or can not see it you will have to output it to a file.

As far as the chkconfig command. Depending on the distro this will add it to the appropriate runlevels with S start and K kill scripts. Usually if it has the LSB header information. Or you can manually create the symlinks.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.