1834432 Members
2636 Online
110067 Solutions
New Discussion

Re: crontab

 
SOLVED
Go to solution
sam kim_1
Frequent Advisor

Re: crontab

i just checked some such as:

# crontab -l
[result : looks fine to me that including
0 9 ** 1-5 /usr/local/bin/uvscan]

# crontab -e
[result : could not connect to ToolTalk service: TT_ERR_PROCID
the process id passed is not valid]

anything wrong ??
Antoanetta Naghiu
Esteemed Contributor

Re: crontab

crontab -e should return you in the vi root (the crontab file.
/var/sool/cron/crontabs/root should be under root ownership and has 444 permission -r--r--r--.
Also, check the envirnonment variable, can you vi whatever with no problems? (terminl setting...)
Rita C Workman
Honored Contributor

Re: crontab

Sam .. Put a space between those two astericks.....

Regards,
sam kim_1
Frequent Advisor

Re: crontab

1) i just changed from ** to * * (with space).

2) but still have same error msg.

3) i might need to test using another file (such as /usr/local/bin/netscape instead of uvscan).

4) or i might need to create an user under /var/spool/cron/crontabs instead of using /var/spool/cron/crontabs/root.

5) in anyway, i am still working on it, and you have good weekend!!
Antoanetta Naghiu
Esteemed Contributor

Re: crontab

Sam, the cron job is going to work. It is not related with crontab -e. If crontab -l reported it corectlly should be ok.
Crontab -e is coming for some strange reason, and I guess is environment setting. Are you using vi as default editor?
Try something as export EDITOR=vi from the command line. After that do again crontab -e If work and put you under vi in that file, just get out.
I have no other idea. Anyway, have a good weekend, cron will work on Monday morning.
sam kim_1
Frequent Advisor

Re: crontab

good morning!

1) i just did:

# EDITOR=vi
# crontab -e
[result is good as well as the result of crontab -l]

2) then, i modified and saved:
from 0 9 * * 1-5 /usr/local/bin/uvscan
to 0 10 * * 1-5 /usr/local/bin/uvscan

then i did:
# /sbin/init.d/cron stop
# /sbin/init.d/cron start

3) then, i was wait til 10 am, because i wanted to see running uvscan automatically at 10 am

4) but, it din not run anything at 10 am or later

5) so i checked:
# ps -ef|grep cron
[resut is:
root 6951 6630 1 10:01:32 pts/0 0:00 grep cron
root 6938 1 0 09:59:06 ? 0:00 /usr/sbin/cron]

6) however, when i ran uvscan manually at the prompt,
it is working if i do : # ./uvscan -cvr /
(it scanning/cleaning all files)
but it doesnt work under : # uvscan -cvr / (error msg says : /sbin/sh: uvscan: not found)

7) that means, i have to modify 'crontab -e'
from 0 10 * * 1-5 /usr/local/bin/uvscan
to 0 10 * * 1-5 /usr/local/bin/./uvscan
or 0 10 * * 1-5 /usr/local/bin/uvscan -cvr /

i know you gave me plenty info/tips already , (and i should assign points already instead of asking relating queations), but pls help me out to resolve this running problem!! thanks!
Victor BERRIDGE
Honored Contributor

Re: crontab

Since cron needs absolute path and your command seems to works with a relative, you are condamned to script writing:
put in your script:
cd /usr/local/bin;
./


Then put your script where you wish and call it with cron using its full path

Good luck
Antoanetta Naghiu
Esteemed Contributor

Re: crontab

1. Do not modify the command on cron. Not yet.
2. vi . profile (beeng on root home's directory)
add /usr/local/bin to the PATH variable:
export PATH=$PATH:/usr/local/bin
3. Run again the script from the command line.
4. If works, is going to work on cron as well.
Good luck.
sam kim_1
Frequent Advisor

Re: crontab

i just did:

# vi . profile
[nothing were there.
i added '/usr/local/bin'
then tried to save, but it doesnt allow to save it]

did i do anything wrong??
Victor BERRIDGE
Honored Contributor

Re: crontab

If you are root, nothing should stop you...
try :
:wq!
Antoanetta Naghiu
Esteemed Contributor

Re: crontab

Sam,
Do
vi .profile, or better vi /etc/profile, or both.
In the vi screen, go to the end, and add the following line:
export PATH=$PATH:/usr/bin/local
Save it (type colon ":" and qw! and enter.
more /etc/profile, more .profile to see your line has been accepted (it is there).
Logout and login again to make the new profile working.
Try to run the script from the command line.
Any better?
Victor BERRIDGE
Honored Contributor

Re: crontab

Sam
I think you edited .
(vi . profile)
Of course then it will not lest you save..
You should have seen a message like
. is a directory
I know that was what Antoanetta put in her before last message, she now has corrected it follow her procedure the ! when saving will let you save on read only files...
Alan Riggs
Honored Contributor

Re: crontab

I recommend NOT adding /usr/local/bin to root's profile. It can be a security risk.

First thing to check is whether cron in fact executed the command you gave it. Look in /var/adm/cron/log for the entries around 10AM. Make sure the command appears and was executed. Most likely, you will see it with a non-zero return code.

Usually this happens because the command depends upon environmental variables and cron executes without a shell environment. The easiest way to check this is to create a script that sources the environment for a user and then executes the command. for example:

#!/bin/ksh
. /etc/profile
. /home/user/.profile
/usr/local/bin/uvscan

Now have cron call this script rather than the program.

You may also wish to redirect the output of the script/command, unless it automatically creates your output files.
sam kim_1
Frequent Advisor

Re: crontab

i did:

# vi /etc/profile
[using 'esc' key then 'j' key to bring a cursor at the very bottom, then using 'esc' then 'i' key to add line as 'export PATH=
$PATH:/usr/local/bin', then using 'esc' key and ':' and then 'wq!' to save it.]

then,
# more /etc/profile
[now, i can see 'export PATH=........']

then
# logout
[sh: logout: not found.]
# exit
# login
[entered user name 'root' and password'xxxxxx']

# uvscan -cvr /
[wow! now this command is working - previously i always typed './uvscan -cvr /' instead of 'uvscan -cvr /'

*** do i still need to modify 'crontab -e'
from '0 10 * * 1-5 /usr/local/bin/uvscan' to
'0 10 * * 1-5 /usr/local/bin/uvscan -cvr /'

???


Victor BERRIDGE
Honored Contributor

Re: crontab

No
Look to see if it works now!
Good luck
Victor
sam kim_1
Frequent Advisor

Re: crontab

1) are there any ways i can test my crontab is working or not using other programs such as netscape

2) in other words, if i setup crontab like
'0 9 * * 1-5 /usr/local/bin/netscape'
tyhe it will run or pop up automatically every morning at 9 am ??
sam kim_1
Frequent Advisor

Re: crontab

i mean '0 9 * * 1-5 /usr/local/bin/uvscan' does not run automatically at 9 am.

i was waiting this morning 9am, but there was nothing happen or running antivirus program.

that is the reason why that i might need to test using another crontab program.
Anthony deRito
Respected Contributor

Re: crontab

sam , in order to check if your crontab is working OK, check the cron log file in /var/adm/cron/log. You will see the entries with timestamps.

Tony
Rick Garland
Honored Contributor

Re: crontab

Programs that are run via the cron are run in the typically run in the background. This may be why you don't see anything. Check the /var/adm/cron/log file to see if any errors were generated, what the errors were, or if it indeed did run as scheduled. Check the root mail to see if any messages came out as well. If you are not redirecting the output, messages will be sent to root mail for the system or to the alias that may be setup.
Antoanetta Naghiu
Esteemed Contributor

Re: crontab

Sam, You do not need to wait 24 hours to test your cron. You can have more than one line in the crontab.
Add something as:
05,15,25,35,45,55 * * * * /usr/bin/more /etc/hosts | mailx -s "List of hosts" root@boxname.domainname
This is going to send to root every 10 min. the /etc/hosts file.
Also you can check the log:
tail /var/adm/cron/log to see the last cron job executed.
Of course, if you modify the crontab file, do not forget to stop and start the cron daemon (/sbin/init.d/cron stop and start).
Victor BERRIDGE
Honored Contributor

Re: crontab

Thats why I said (and others after...) to write a script where you can set the environment variable you need and customize...
Then in your cronfile your line could look like:
0 9 * * 1-5 /usr/local/bin/customuvscan >>/mylogdir/cusomvgscan.log 2>>/mylogdir/customvgscan.err

Some already have reminded you to be more generous with the contributors who all have given time and good advices...
Antoanetta Naghiu
Esteemed Contributor

Re: crontab

I agree with Victor.
sam kim_1
Frequent Advisor

Re: crontab

1) i just did as follows:

# cd /var/adm/cron
# ls
# more log

[result is:

! *** cron started *** pid=7411 Tus Aug
04:31:10 EDT 2000

>CMD: /usr/sbin/dmesg - >>/var/adm/messages
>root 7413 c Tue Aug 29 04:35:00 EDT 2000
>CMD: /usr/sbin/dmesg - >>/var/adm/messages
>root 7415 c Tue Aug 29 04:45:00 EDT 2000
>CMD: /usr/sbin/dmesg - >>/var/adm/messages
>root 7418 c Tue Aug 29 04:55:00 EDT 2000
.
.
.
.
>CMD: /usr/sbin/dmesg - >>/var/adm/messages
>root 7468 c Tue Aug 29 08:55:00 EDT 2000
>CMD: /usr/local/bin/uvscan
>root 7470 c Tue Aug 29 09:00:00 EDT 2000
.
.
.
>CMD: /usr/sbin/dmesg - >>/var/adm/messages
>root 7516 c Tue Aug 29 10:05:00 EDT 2000
#

2)i can see uvscan is there. this means it was running in the back but i couldnt see the actual running screen visually???

Rick Garland
Honored Contributor

Re: crontab

That is correct. The uvscan process did run by the appearance of the log.

Does the uvscan keep a log file of its own? If so, check it as well to see if any additional info from the uvscan run is present?
(It did what, when, why, etc...)
Antoanetta Naghiu
Esteemed Contributor

Re: crontab

That means that the cron is functional. That means, it started the job. What the job is doing is not cron responsability.
Particulary, for your issue, what this uvscan is doing? If giving output to the screen, try to capture them in a file that can be analyze latter, something as:
...... /usr/local/bin/uvscan >/mylocation/output (or whatever you like).

Run it first from command line. If worked, is working from cron as well.