Sponsored Content
Full Discussion: cronjob Command for Shutdown
Operating Systems Linux Red Hat cronjob Command for Shutdown Post 302586024 by admin_xor on Friday 30th of December 2011 02:30:43 AM
Old 12-30-2011
You can run the cron job at 5:55 PM with the following modifications. It's better if you could save the script in a file and make it executable and run it in cron.
Code:
#!/bin/bash

# initshut.sh file
/bin/cat /root/machines | while read sys; do
   # let's put it in the background and move on to the next machine
   ( /usr/bin/ssh root@$sys '/sbin/shutdown -h +10 "The system is going down after 10 minutes. Please save your work and log off before that. --Admin"' ) &
done

Please note the single and double quotes. Without their proper usage, the command will not be executed.

Then, make a crontab entry like this:
Code:
55 17 * * * '/root/initshut.sh >/dev/null 2>&1'


Last edited by admin_xor; 12-30-2011 at 03:40 AM..
This User Gave Thanks to admin_xor For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

shutdown question from command line

solaris 10 logged in as root to command line...want to shut the system down....could not do this....when i chose shutdown the system seemed to squawk at me saying i'd lose whatever i was working on would be lost unless i logged out...after proceeding through this it took me to the gui log in... (6 Replies)
Discussion started by: drisnya
6 Replies

2. Shell Programming and Scripting

Need a cronjob command

Dear Exerts, I want to schedule a script which could run after every 35 minutes. please find below the command but it is not woring and running after every 35 minutes. 35 * * * * /opt/home/backup/test_dir/abc.sh > /opt/home/backup/test_dir/abc_cronlog.txt Please tell me what is the problem... (7 Replies)
Discussion started by: shary
7 Replies

3. AIX

shutdown command

Hi, After issuing shutdown -F or shutdown -F now my server is getting restarted. Any Idea? (3 Replies)
Discussion started by: manoj.solaris
3 Replies

4. UNIX for Dummies Questions & Answers

Script to force Oracle database shutdown when shutdown immediate does not work

I have Oracle 9i R2 on AIX 5.2. My Database is running in shared server mode (MTS). Sometimes when I shutdown the database it shutsdown cleanly in 4-5 mints and sometimes it takes good 15-20 minutes and then I get some ora-600 errors and only way to shutdown is by opening another session and... (7 Replies)
Discussion started by: aixhp
7 Replies

5. OS X (Apple)

Problems using shutdown -u command

I have a smart-ups connected to my OS X Snow Leopard server ver. 10.6. Based on the docs and forums I read, I have been trying to use the software provided by APC, PCNS. I have also tried to just use the UPS communications cable provided and use the OS' "UPS options". Neither of them work exactly... (1 Reply)
Discussion started by: mckorn99
1 Replies

6. AIX

Shutdown command

Hi, is there a difference between shutdown -Fand shutdown -h now? (3 Replies)
Discussion started by: x_adm
3 Replies

7. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

8. Shell Programming and Scripting

Exit script when shutdown or reboot command is given

This is probably a simple question, but I'm new with writing scripts for Linux (IPFire in this case) and Google wasn't helpful with this. When creating a script, what is the best and/or proper way to have it exit automatically if the reboot or shutdown command is given? If that's even... (2 Replies)
Discussion started by: bartgrefte
2 Replies

9. UNIX for Dummies Questions & Answers

Top Command Output is not coming via Cronjob

Dear All, I created a small script to get the CPU, GIS usage etc automatically. However when i run this script manually its working , but when i run through cronjob i am not getting any output. Can anyone please help me on this. I am using SuseLinux. Thank you in advance. #!/bin/sh {... (2 Replies)
Discussion started by: Nitin Kapoor
2 Replies

10. Shell Programming and Scripting

Issue with shutdown command in script (MacOS High Sierra)

Hello, I have a backup script that runs an rsync backup to an external drive. I use the script frequently on Windows and Linux and have installed it on a Mac. The script has an option to run shutdown after the backup has completed. Since backup can take hours to run, this is an option that is... (10 Replies)
Discussion started by: LMHmedchem
10 Replies
apticron(1)						      General Commands Manual						       apticron(1)

NAME
apticron - Generate a mail listing packages which are pending an upgrade SYNOPSIS
apticron [--cron] DESCRIPTION
apticron is a shell script which generates a mail with a list of all packages currently pending an upgrade, as well as summary of changes - using apt-listchanges - to a configurable Email address. apticron is mainly intended for automatic notification of pending security updates but can also be used in many other situations where timely updates are necessary. The --cron option is only meant to be used when invoked by cron in order to run no more than once a day. FILES
/etc/apticron/apticron.conf Configuration file, Email address to mail and profile for use with apt-listchanges are configurable. /etc/cron.d/apticron Cron job for executing apticron daily. /etc/cron.daily/apticron Fallback cron script for executing apticron (if no crond running or system down at designated time). /var/lib/misc/apticron.cron Time stamp file used by apticron when invoked with --cron option. SEE ALSO
apt-get(8), apt-listchanges(1), cron(8) AUTHOR
Apticron was initially developed by Colm MacCarthaigh <colm.maccarthaigh@heanet.ie> with contributions from Marc Sherman <msherman@projec- tile.ca>. Since 2006 it is maintained and improved by Tiago Bortoletto Vaz <tiago@debian.org>. apticron(1)
All times are GMT -4. The time now is 04:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy