Instead of listing contents of directory /var/spool/cron/crontabs or executing su – [user] (what I was doing for years now, as silly as I can be), I found out this morning that a command exists for that (with AIX this is actually often the case ūüôā ) : cronadm

List all crontabs with submission time

 # cronadm cron -v | sort -k 11
Crontab file: sys        Submission time: Fri Oct  7 15:56:29 DFT 2005
Crontab file: uucp       Submission time: Mon Jun 19 16:38:47 DFT 2006
Crontab file: cft        Submission time: Wed Sep 23 08:30:25 DFT 2009
Crontab file: oracle     Submission time: Tue Dec 24 09:27:43 NFT 2013
Crontab file: orainst    Submission time: Thu Apr 18 15:01:19 DFT 2013
Crontab file: root       Submission time: Tue Jan 29 10:47:54 NFT 2013

(the sort -k 11 sorts the entries by year,  useful in order to investigate some recent changes in crontabs)

Erase crontabs

Only root is allowed to use cronadm, so even if one is the owner of the crontab, he won’t be able to remove it (he may edit it and empty it, of course, but not remove it via cronadm.)

root@lpar1:/root# cronadm cron -l user
* * * * * echo hi
root@lpar1:/root# cronadm cron -v user
crontab file: user   submission time: Tue Dec 24 10:18:47 2013
root@lpar1:/root# su - user
user@lpar1# crontab -l
* * * * * echo hi
user@lpar1# cronadm cron -r user
ksh: cronadm: cannot execute
user@lpar1# logout
root@lpar1:/root# cronadm cron -r user
root@lpar1:/root# cronadm cron -v user
root@lpar1:/root#

It works wit at jobs too

root@lpar1:/root# echo hi | at 10:49
job root.1387878540.a at Tue Dec 24 10:49:00 2013
root@lpar1:/root# cronadm at -l
root.1387878540.a       Tue Dec 24 10:49:00 2013
root@lpar1:/root#

…Alright, it doesn’t seems as useful as the ¬ę¬†cron¬†¬Ľ one, but nonetheless, worths mentioning it.

Links

Cronadm page

 

Share Button
cronadm : list crontabs or at jobs, and display their status with a simple command
Tagg√© sur :            

Laisser un commentaire