LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   cron job not running (https://www.linuxquestions.org/questions/linux-software-2/cron-job-not-running-215844/)

nitin_batta 10-09-2004 03:49 AM

Quote:

How do I change the suid on a binary?

The crontab entry is 0 1 * * * init 0

I have also tried

0 1 * * * /sbin/init 0
0 1 * * * "/sbin/init 0" (so the path is not the problem)
0 1 * * * /sbin/shutdown -h now
0 1 * * * "/sbin/shutdown -h now" (so using a diff. command is not the problem)

None have worked.

You can set the suid bit using the chmod command.

Code:

# chmod 4666 /sbin/shutdown
A 4 here sets the suid bit. I dunn have a linux system with me as of now but man chmod:study: could help.

vincebs 10-30-2004 12:35 AM

Hmm something's bizarre... I did chmod 555 to shutdown so now I can shutdown without being root

but the cron job still doesn't load. This time I decided to use KCron to schedule my job. Here's my output for crontab -l:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/kde-vicente/kcronCPW9Ja.tmp installed on Fri Oct 29 15:32:53 2004)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
# apagación
0,15,30,45 0,1,2,3 * * 1,2,3,4,5 shutdown -h now
# apagación weekend
30 1,2,3,4,5 * * 6,7 shutdown -h now
# This file was written by KCron. Copyright (c) 1999, Gary Meyer
# Although KCron supports most crontab formats, use care when editing.
# Note: Lines beginning with "#\" indicates a disabled task.

It's 1:34am on Saturday and the scheduled 1:30 shutdown still hasn't come.

nitin_batta 10-30-2004 02:12 AM

Dude can you make set the uid bit on shutdown

assuming you have the binary shutdown at /sbin/shutdown

Code:

now become root and

#chmod 4555 /sbin/shutdown

Now put it normal crontab and check.
Only one issue here is any user on the machine can shut it down.

Nitin :)

cbe 10-30-2004 04:12 AM

Have you tried this:

Edit as root: /etc/crontab

0 1 * * * root /sbin/shutdown -h now

This will execute the command as root (assuming cron is working correctly) w/out sudo.

---

If you were want to use SUDO you have to edit the sudoers file and add a NOPASSWD:shutdown to that user to allow it to shutdown without a password.

example susoers file:

User_Alias SHUTDWN = user
Cmnd_Alias SHUTDOWN = /sbin/shutdown
SHUTDWN = ALL=NOPASSWD:SHUTDOWN

Then you could use crontab as user with SUDO to shutdown the machine w/out a password.


Hopfully this helps in some way.

vincebs 10-30-2004 01:27 PM

Thanks guys, it works now. The main problem was with the permissions to run shutdown and putting that command's path in.

:)


All times are GMT -5. The time now is 04:52 AM.