cancel
Showing results for 
Search instead for 
Did you mean: 

cron job

unixshell
Occasional Contributor

cron job

i need to run cron job for every 30 mins to check tat inetd is running or not..

#cat /tmp/inetdtest
ps -ef | grep inetd >> /tmp/inetdcheck

crontab -e

30 * * * * sh /tmp/inetdtest

but cron job is not running ,, i am not getting the updates in /tmp/inetdcheck

i have checked the entry in var/adm/cron/cron.allow file also

11 REPLIES
Johnson Punniyalingam
Honored Contributor

Re: cron job

what's permission of your /tmp/inetdtest file ?

ll -l /tmp/inetdtest

Change file permission

chmod 755 /tmp/inetdtest

rename the file to

mv /tmp/inetdtest /tmp/inetdtest.sh

crontab - entry as below also check space

30 * * * * /tmp/inetdtest.sh

Hope this Helps,

Regards,
Johnson
Problems are common to all, but attitude makes the difference
Dennis Handly
Acclaimed Contributor

Re: cron job

>ps -ef | grep inetd >> /tmp/inetdcheck

This is missing the interpreter line and replace grep by ps -C:
#!/usr/bin/sh
UNIX95=EXTENDED_PS ps -f -C inetd >> /tmp/inetdcheck

>30 * * * * sh /tmp/inetdtest

This should be:
0,30 * * * * /tmp/inetdtest

>but cron job is not running

Are you getting any mail messages?

> Johnson: Change file permission

Right. Better to use symbolic modes:
chmod a+x /tmp/inetdtest
Vishu
Trusted Contributor

Re: cron job

Hi,

first, check the permissions of your file /tmp/inetdtest. It should be executable. so do,

# chmod 755 /tmp/inetdtest

You can omit specifying the 'sh' in your crontab file.

# crontab -e

30 * * * * /tmp/inetdtest
Steven Schweda
Honored Contributor

Re: cron job

> ps -ef | grep inetd >> /tmp/inetdcheck

You noticed that this may find itself, as
well as the real "inetd" process?

> [...] replace grep by ps -C:

Better, but anyone can write a program named
"inetd", and run it.

What are you really trying to test? Are you
looking for a running program named "inetd",
or do you wish to see if (the real) "inetd"
is doing its job properly? It might make
more sense to use a program like cURL,
Telnet, or wget, to see if you can reach some
real service (one which "inetd" would need to
start).
Suraj K Sankari
Honored Contributor

Re: cron job

Hi,
Insted of this
>30 * * * * sh /tmp/inetdtest

It should like this
0,30 * * * * /tmp/inetdtest

Cross check your /tmp/inetdtest file it should be having executed permissions

Suraj
unixshell
Occasional Contributor

Re: cron job

hi steven

Better, but anyone can write a program named
"inetd", and run it.

What are you really trying to test? Are you
looking for a running program named "inetd",
or do you wish to see if (the real) "inetd"
is doing its job properly? It might make
more sense to use a program like cURL,
Telnet, or wget, to see if you can reach some
real service (one which "inetd" would need to
start).


how to do with using cURL,TELNET OR wget
Viktor Balogh
Honored Contributor

Re: cron job

>how to do with using cURL,TELNET OR wget

if you have a http server, you can try this:

#!/usr/bin/sh
wget http://localhost/index.html 1>&2 2>/dev/null
if [ $? -ne "0" ]
then
echo "inetd might not running! Please check"
fi
****
Unix operates with beer.
Viktor Balogh
Honored Contributor

Re: cron job

it goes the same with curl:

#!/usr/bin/sh
curl http://localhost/index.html 1>&2 2>/dev/null
if [ $? -ne "0" ]
then
echo "inetd might not running! Please check"
fi
****
Unix operates with beer.
Steven Schweda
Honored Contributor

Re: cron job

> how to do with using cURL,TELNET OR wget

How to do _WHAT_?

> What are you really trying to test?

Still wondering...

> [...] 1>&2 2>/dev/null

Personally, rather than send this output
directly to "/dev/null", I'd save the it, and
include it in the e-mail which my script
would send to the system manager if the
operation failed. (Which is what I do in the
DCL procedure which I use on my main VMS
system to check on the Web server. My script
also searches the output for a "200" status
value in the response from the Web server.
As usual, many things are possible, depending
on exactly what one wishes to test.)

> echo "inetd might not running! Please check"

Not what I'd say. If I were testing the Web
server, and the test failed, then I'd
probably say something like "WWW Server Test
Failure.", and follow that with the details,
like, say, "Status 200 missing from log
file.", or "Log file () was
not created.", or something like that, and
leave the interpretation to the victim.

But that's just my opinion.
Steven Schweda
Honored Contributor

Re: cron job

> it goes the same with curl:

And a Forum search for keywords like, say,
telnet expect
might find examples of the use of Telnet in
a script, too. Or, one could use Kermit,
which has its own, built-in scripting
capability.
TTr
Honored Contributor

Re: cron job

As mentioned above, there are scripting defficincies to say the least in the way you are checking for a running inted.

If inetd is not running, the command "inetd -c" will output "inetd:There is no inetd running" and exit code 1. If inetd is running, "inetd -c" will reload the config file which is harmless if no config changes have been made and exit code 0.

Of course inetd could be running and be in a hung state so as mentioned above, the real test would be to use a service that is started by inetd.

> crontab -e
> but cron job is not running
> i have checked the entry in var/adm/cron/cron.allow file also


This may be a cron problem.
1. What does crontab -l show?
2. Have you checked the cron log file to see if the job is executed or it has errors?
3. Have you checked the root's email to see if cron reports any errors?