crontab in AIX

Hi all, i am trying to reduce the file size of /var/adm/wtmp in my AIX servers and im using the method cp /dev/null /var/adm/wtmp to reduce it. I thought of automating it by including this command into crontab. Surprisingly, it doesn't work once i put into crontab, there is no error message thrown out, no messages, no output in fact it seems as though that command was not executed at all. How come? I tried typing manually the command and it works it only doesn't work in crontab. Any suggestion?

Please give an example of the entry from the crontab. I bet it is because you are not using the absolute path of cp as in /usr/bin/cp.

I tried with full path and it doesnt work too. By the way the command i use is:

1 * * * * /usr/bin/cp /dev/null /var/adm/wtmp

THe reason i let it run every minute is because at this moment i want to monitor hence a 1 minute wait is the most appropriate.

No wonder /usr/bin/cp /dev/null > /var/adm/wtmp

I am wrong now disregard my last entry!

Try /usr/bin/cat /dev/null > /var/adm/wtmp

How come i need to add the > but via command line i do not need to use that? How often will it update the log file for cron? Once i've modified i do not see it in the /var/adm/cron/log file immediately. It still doesn't work after i did that:

1 * * * * /usr/bin/cp /dev/null > /var/adm/wtmp

Hi John, even /usr/bin/cat doesn't work :frowning:

Well I just run the command:
00,01,02,03 * * * * /usr/bin/cat /dev/null > /var/adm/wtmp 1>/test.out 2>&1
and wtmp now = 0 and the output file test.out is empty which is as it should be.

try ....

/usr/bin/echo > /var/adm/wtmp

if that doesn't work --- reboot the server and then check again all those other commands you tried ...

btw, how did you reactivate the crontab after your edits?

What do you mean justice when you say how did you re-activate the crontab? There is no need to re-activate anything cron is still running and dynamically reads the crontab!

Hi Johnf, hmm that command of yours work but not mine, what's the difference in the time that you placed? you put it as 00, 01, .... whereas i only put a 1 there as every single minute right? Hi Light, i did not restart the cron but i did try, i used the kill command to restart, with the option -1 followed by the PID. Is that the correct way? John, can you explain please thanks a lot guys.

if the way the crontab was edited is through editing /var/spool/cron/crontabs/root directly, the crontabs may not be updated accordingly until cron is restarted ... if the crontab was edited using "crontab -l > /tmp/file; vi /tmp/file" then cron may not even know of the changes until "crontab /tmp/file" is issued ... if the crontab was updated using "crontab -e" then there is no problem ...

btw, the message i wrote was for smallbook ... you just happened to put in your message while i was composing mine ...

No! The 1 means it will run 1 minute past every hour and no more. The 00,01,02,03 etc... means run every minute on every hour. That is why it was not working. I was to interested in the command to spot the minute / hour entry so I tried it myself to make sure.

Oops sorry just ice, i only remember the quote you have, which is light hence i put in a wrong name sorry sorry. I used the command crontab -e. Hi John, icic now i notice my mistake so i guess now i have to read up how to set it to run every week to clear up the wtmp file. I guess now with your command i can change it to cp comamnd and it will still work right?

Hmm guys, i tried the command on other servers and it doesn't work anymore??!!! what happened? i copied the exact command that John you wrote there. I only managed2 let it work in the first server i was working on. HELPPPPP

have you tried to do the echo redirect command like i suggested? if that also doesn't work on the other servers, are you logged in as root on them and do you have the proper permissions to do it? some places even root cannot modify the files because of extra permissions that have been set for security purposes ...

good luck!

the command ">/var/adm/wtmp" in root crontab will clear the file

edit: edit crontab with crontab -e

I usually solve these issues by writing a script in my home bin directory, then calling it via cron. That way, I can test it and so far haven't had issues with things working differently in cron. Well, usually.

HTH

thanks guys it is working now. Thanks for all the suggestions and feedback...