F
F
fuzzZy232016-09-15 15:36:56
linux
fuzzZy23, 2016-09-15 15:36:56

Cron is not running. Server reboot. What am I doing wrong?

Good afternoon.
The server has CentOS release 6.7 (Final) installed. With Linux I encounter for the first time, zero knowledge. All at the level of "google" and logic. Therefore, I ask for advice:
The task is banal: it is necessary to restart the server every day at 07:00.
Done:
1. Created a script along the way

etc/scripts/shoutdown.sh

2. Made shoutdown.sh executable
3. Added a script to shoutdown.sh
shoutdown -r now

3. With the help of MC, registered cron
0 7 * * * /etc/scripts/shoutdown.sh

in the root file, at
/var/spool/cron

What I tried:
1. I could not figure out where to look at the server operation log, put ip on ping for the night. There were no packets lost, so the server did not reboot.
2. Manually launched the script with the command
sh /etc/scriptpts/shoutdown.sh

The server went into reboot. Those. working script. So the problem is in cron.
3. Found cron log. It has a script reminder at 07:00:01
cf15d0e11af0494f966b9c45d516f59c.png
4. The crontab -l command shows my command.
5. When I type crontab -e I see this:
dd550efdae1646b1890516c2934c2f9d.png
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
R
Rsa97, 2016-09-15
@fuzzZy23

Either the script must be run explicitly by specifying in crontab /bin/sh /etc/scripts/shoutdown.sh, or the first line of the script must be an indication of the program that processes the script#!/bin/sh

S
Saboteur, 2016-09-15
@saboteur_kiev

Something and somewhere you messed up with the scripts.
You don't need a script for this, just write in the crontab:
0 7 * * * /sbin/shutdown -r now

@
@gridmit, 2016-09-15
_

sudo crontab -e
0 7 * * * /etc/scripts/shoutdown.sh 2>>/tmp/error.log
when it works, look in the file for what the error is

V
Vadim K, 2016-09-15
@OLQLOSH

Isn't it easier:
# vi /etc/crontab
0 7 * * * root shutdown -r now
# /etc/init.d/crond restart
and you don't need to create any files with scripts for a simple cron restart)

Y
Yuri Chudnovsky, 2016-09-15
@Frankenstine

As Saboteur rightly said - you don't need a script; but in general, the mistake is that you call shoutdown without specifying the full path to it, and the cron does not search for executable files in order to speed up processing (and probably also for security reasons).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question