LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-09-2004, 03:49 AM   #31
nitin_batta
Member
 
Registered: Aug 2004
Location: India
Distribution: Redhat Enterprise Server 2.1
Posts: 96

Rep: Reputation: 15

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 could help.
 
Old 10-30-2004, 12:35 AM   #32
vincebs
Member
 
Registered: Oct 2003
Location: Mississauga, ON
Distribution: Ubuntu 9.04
Posts: 496

Original Poster
Rep: Reputation: 30
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.
 
Old 10-30-2004, 02:12 AM   #33
nitin_batta
Member
 
Registered: Aug 2004
Location: India
Distribution: Redhat Enterprise Server 2.1
Posts: 96

Rep: Reputation: 15
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

Last edited by nitin_batta; 10-30-2004 at 02:14 AM.
 
Old 10-30-2004, 04:12 AM   #34
cbe
LQ Newbie
 
Registered: Jul 2001
Posts: 19

Rep: Reputation: 0
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.
 
Old 10-30-2004, 01:27 PM   #35
vincebs
Member
 
Registered: Oct 2003
Location: Mississauga, ON
Distribution: Ubuntu 9.04
Posts: 496

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

 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Screen in a cron job LinuxGeek Linux - Software 1 08-03-2005 12:11 AM
script not running as a cron job sanjith11 Programming 5 11-23-2004 08:42 AM
Cron job not running in slackware9.1 marri Linux - Software 2 05-06-2004 06:54 AM
Cron job not running? james_cwy Linux - Newbie 6 12-14-2003 08:24 PM
Cron Job Not Running pzorn Linux - General 4 10-02-2003 01:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration