Web Hosting Talk







View Full Version : Finding cron from customers


WWWhost
07-28-2004, 07:32 AM
hi all,
i have some customers wich cron's on server(can see them in cron log) However i cannot finde them on my server...
Is there a way to finde customers cronjobs (setup by ssh or CPanel) I have to disable a cronjob created an user.

Thanks a lot

RutRow
07-28-2004, 07:35 AM
"crontab -l user" to view their crontab.
"crontab -e user" to edit their crontab.
You can also do "man crontab". Note: you must be root to edit someone else's crontab.

Slidey
07-28-2004, 07:35 AM
cd /var/spool/cron

ls -l

sprintserve
07-28-2004, 08:01 AM
If you don't want your users using cron, disable it in WHM (using feature manager) and don't allow them access to it. Otherwise, it's going to be an exercise to keep up with the programs they run.

WWWhost
07-28-2004, 08:42 AM
thanks a lot for help.

RutRow--- if i try to edit a cron with crontab -e username i recive an error as below:


root@server [/var/spool/cron]# crontab -e username
crontab: usage error: no arguments permitted after this option
usage: crontab [-u user] file
crontab [-u user] { -e | -l | -r }
(default operation is replace, per 1003.2)
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
root@server [/var/spool/cron]#

WWWhost
07-28-2004, 09:21 AM
there is another thing. I cannot edit the files form a user in /var/spool/cron as when i open a cron i see this:
--------------
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/home/user/.crontab installed on Fri Jul 02 03:22:17 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
MAILTO="userid"
35 * * * * ~userid/www/cgi-bin/data/scriptname.pl
--------------

Going to /home/user/.crontab there is no .crontab file.


can anyone help me out?

thanks a lot

JohnCrowley
07-28-2004, 09:39 AM
crontab -u username -e

That will allow you to edit a user's cron.

- John C.

RutRow
07-28-2004, 10:15 AM
Originally posted by JohnCrowley
crontab -u username -e

That will allow you to edit a user's cron.

- John C.

Interesting... "crontab -e user" works just fine on my box. Then again, I run Slackware :)

WWWhost
07-28-2004, 12:27 PM
i am on RH9 and it does no work..

:(

choon
07-28-2004, 12:31 PM
If you need all crontab or report you each of your users crontab via email, let me know so that I can post a very simple shell script ;)

amal
07-28-2004, 02:15 PM
Originally posted by choon
If you need all crontab or report you each of your users crontab via email, let me know so that I can post a very simple shell script ;)

Yes, sure I also interested

choon
07-28-2004, 03:12 PM
Cut and paste the below and name it as /root/crontabreport.sh:
#!/bin/sh

myemail=$1
if [ -n "$myemail" ] ; then
mycrontmp=/root/cron.tmp.$$
# get current user list
for i in `cat /etc/passwd | cut -f1 -d :`; do
echo "--------------------------------------------------"
echo "Username: ${i}"
echo "--------------------------------------------------"
crontab -u ${i} -l 2>&1
echo "--------------------------------------------------"
done > $mycrontmp
cat $mycrontmp | mail -s "crontab report for `hostname`" ${myemail}
rm -f $mycrontmp
else
echo "Please supply a valid email address to get the report."
exit
fi
How to use?
sh /root/crontabreport.sh YOUREMAIL
Replace YOUREMAIL with real email of yours ;)

sawbuck
07-28-2004, 04:30 PM
Thanks choon!

blockcipher
07-28-2004, 04:38 PM
That's a cool script. Thanks chooon.

RutRow
07-28-2004, 05:02 PM
Originally posted by WWWhost
i am on RH9 and it does no work..

:(

I am curious what cron RH uses. Slackware 10 uses Dillion's Crond Daemon 2.3.3.

choon
07-28-2004, 05:33 PM
Originally posted by blockcipher
That's a cool script. Thanks chooon.
:uzi: Not chooon
It is choon :angel:

blockcipher
07-28-2004, 05:43 PM
My typing hasn't been that good today, sorry :p

Dacsoft
07-28-2004, 07:01 PM
really nice script choon

WWWhost
07-29-2004, 09:02 AM
greate script thanks

dynamicnet
07-29-2004, 10:03 AM
Greetings:

Good script choon.

FYI, for those who use LogWatch, you will see user cron scripts in the cron section.

Thank you.

hostito
07-29-2004, 10:23 AM
Thanks choooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooon :)

Just kidding ;) great scriptie!

choon
07-29-2004, 11:05 AM
Thanks and hope that buggy little script helps someone ;)
:puke: hostito :stickout :D