cron job is not doing anything
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
I am trying to run a cron job that runs every 10 minutes to kill the process sshd.
so I did open /etc/crontab as a root and inserted the following line.
*/1 * * * * pkill sshd
I checked with systemctl status sshd
after 1,2,3 minutes.
And I see sshd still up & running.
I am using centos7.
process cron scheduling
add a comment |Â
up vote
-1
down vote
favorite
I am trying to run a cron job that runs every 10 minutes to kill the process sshd.
so I did open /etc/crontab as a root and inserted the following line.
*/1 * * * * pkill sshd
I checked with systemctl status sshd
after 1,2,3 minutes.
And I see sshd still up & running.
I am using centos7.
process cron scheduling
2
IsnâÂÂt there a*
missing?
â nohillside
Jan 12 at 20:43
Yes I added the start and still the same issue
â alkabary
Jan 12 at 20:58
what exactly are you trying to do? disable ssh? better methods. kick off idle ssh connections? better methods. edit your question and tell us your end goal and we can give better help.
â ivanivan
Jan 12 at 23:04
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am trying to run a cron job that runs every 10 minutes to kill the process sshd.
so I did open /etc/crontab as a root and inserted the following line.
*/1 * * * * pkill sshd
I checked with systemctl status sshd
after 1,2,3 minutes.
And I see sshd still up & running.
I am using centos7.
process cron scheduling
I am trying to run a cron job that runs every 10 minutes to kill the process sshd.
so I did open /etc/crontab as a root and inserted the following line.
*/1 * * * * pkill sshd
I checked with systemctl status sshd
after 1,2,3 minutes.
And I see sshd still up & running.
I am using centos7.
process cron scheduling
edited Jan 12 at 20:57
asked Jan 12 at 20:28
alkabary
574823
574823
2
IsnâÂÂt there a*
missing?
â nohillside
Jan 12 at 20:43
Yes I added the start and still the same issue
â alkabary
Jan 12 at 20:58
what exactly are you trying to do? disable ssh? better methods. kick off idle ssh connections? better methods. edit your question and tell us your end goal and we can give better help.
â ivanivan
Jan 12 at 23:04
add a comment |Â
2
IsnâÂÂt there a*
missing?
â nohillside
Jan 12 at 20:43
Yes I added the start and still the same issue
â alkabary
Jan 12 at 20:58
what exactly are you trying to do? disable ssh? better methods. kick off idle ssh connections? better methods. edit your question and tell us your end goal and we can give better help.
â ivanivan
Jan 12 at 23:04
2
2
IsnâÂÂt there a
*
missing?â nohillside
Jan 12 at 20:43
IsnâÂÂt there a
*
missing?â nohillside
Jan 12 at 20:43
Yes I added the start and still the same issue
â alkabary
Jan 12 at 20:58
Yes I added the start and still the same issue
â alkabary
Jan 12 at 20:58
what exactly are you trying to do? disable ssh? better methods. kick off idle ssh connections? better methods. edit your question and tell us your end goal and we can give better help.
â ivanivan
Jan 12 at 23:04
what exactly are you trying to do? disable ssh? better methods. kick off idle ssh connections? better methods. edit your question and tell us your end goal and we can give better help.
â ivanivan
Jan 12 at 23:04
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
0
down vote
accepted
There are several problems here (are you sure you wouldn't be better off using auto logoff?):
*/1 * * * * pkill sshd
The "/1" should be "/10" to run every ten minutes.
There is no user specification: I suspect that you'll find some message to the tune of "unknown user pkill" in the syslog.
It's to be seen whether pkill
is in cron's PATH when it runs.
All in all, I'd try with:
*/10 * * * * root /path/to/pkill sshd
Then you have the problem of sshd restarting after having been killed, as D'Arcy Nader pointed out in his answer (but that's probably all right, otherwise you wouldn't want to do serial killing through cron).
add a comment |Â
up vote
2
down vote
you have to edit the file sshd.service
and change the line from:
Restart=on-failure
to
Restart=no
and when you'll kill the process it will not restart.
add a comment |Â
up vote
2
down vote
Why don't you just stop the process all together? etc/init.d/sshd stop
If you you are worried it will start up on the next reboot, you could add this command to crontab via crontab -e
add */1 * * * * etc/init.d/sshd stop
. This is untested at the moment.
https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-autotasks.html
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
There are several problems here (are you sure you wouldn't be better off using auto logoff?):
*/1 * * * * pkill sshd
The "/1" should be "/10" to run every ten minutes.
There is no user specification: I suspect that you'll find some message to the tune of "unknown user pkill" in the syslog.
It's to be seen whether pkill
is in cron's PATH when it runs.
All in all, I'd try with:
*/10 * * * * root /path/to/pkill sshd
Then you have the problem of sshd restarting after having been killed, as D'Arcy Nader pointed out in his answer (but that's probably all right, otherwise you wouldn't want to do serial killing through cron).
add a comment |Â
up vote
0
down vote
accepted
There are several problems here (are you sure you wouldn't be better off using auto logoff?):
*/1 * * * * pkill sshd
The "/1" should be "/10" to run every ten minutes.
There is no user specification: I suspect that you'll find some message to the tune of "unknown user pkill" in the syslog.
It's to be seen whether pkill
is in cron's PATH when it runs.
All in all, I'd try with:
*/10 * * * * root /path/to/pkill sshd
Then you have the problem of sshd restarting after having been killed, as D'Arcy Nader pointed out in his answer (but that's probably all right, otherwise you wouldn't want to do serial killing through cron).
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
There are several problems here (are you sure you wouldn't be better off using auto logoff?):
*/1 * * * * pkill sshd
The "/1" should be "/10" to run every ten minutes.
There is no user specification: I suspect that you'll find some message to the tune of "unknown user pkill" in the syslog.
It's to be seen whether pkill
is in cron's PATH when it runs.
All in all, I'd try with:
*/10 * * * * root /path/to/pkill sshd
Then you have the problem of sshd restarting after having been killed, as D'Arcy Nader pointed out in his answer (but that's probably all right, otherwise you wouldn't want to do serial killing through cron).
There are several problems here (are you sure you wouldn't be better off using auto logoff?):
*/1 * * * * pkill sshd
The "/1" should be "/10" to run every ten minutes.
There is no user specification: I suspect that you'll find some message to the tune of "unknown user pkill" in the syslog.
It's to be seen whether pkill
is in cron's PATH when it runs.
All in all, I'd try with:
*/10 * * * * root /path/to/pkill sshd
Then you have the problem of sshd restarting after having been killed, as D'Arcy Nader pointed out in his answer (but that's probably all right, otherwise you wouldn't want to do serial killing through cron).
answered Jan 12 at 21:17
LSerni
2,326615
2,326615
add a comment |Â
add a comment |Â
up vote
2
down vote
you have to edit the file sshd.service
and change the line from:
Restart=on-failure
to
Restart=no
and when you'll kill the process it will not restart.
add a comment |Â
up vote
2
down vote
you have to edit the file sshd.service
and change the line from:
Restart=on-failure
to
Restart=no
and when you'll kill the process it will not restart.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
you have to edit the file sshd.service
and change the line from:
Restart=on-failure
to
Restart=no
and when you'll kill the process it will not restart.
you have to edit the file sshd.service
and change the line from:
Restart=on-failure
to
Restart=no
and when you'll kill the process it will not restart.
answered Jan 12 at 20:43
D'Arcy Nader
678414
678414
add a comment |Â
add a comment |Â
up vote
2
down vote
Why don't you just stop the process all together? etc/init.d/sshd stop
If you you are worried it will start up on the next reboot, you could add this command to crontab via crontab -e
add */1 * * * * etc/init.d/sshd stop
. This is untested at the moment.
https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-autotasks.html
add a comment |Â
up vote
2
down vote
Why don't you just stop the process all together? etc/init.d/sshd stop
If you you are worried it will start up on the next reboot, you could add this command to crontab via crontab -e
add */1 * * * * etc/init.d/sshd stop
. This is untested at the moment.
https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-autotasks.html
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Why don't you just stop the process all together? etc/init.d/sshd stop
If you you are worried it will start up on the next reboot, you could add this command to crontab via crontab -e
add */1 * * * * etc/init.d/sshd stop
. This is untested at the moment.
https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-autotasks.html
Why don't you just stop the process all together? etc/init.d/sshd stop
If you you are worried it will start up on the next reboot, you could add this command to crontab via crontab -e
add */1 * * * * etc/init.d/sshd stop
. This is untested at the moment.
https://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-autotasks.html
edited Jan 14 at 11:50
Jeff Schaller
31.8k848109
31.8k848109
answered Jan 12 at 22:18
Govna
7817
7817
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416669%2fcron-job-is-not-doing-anything%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
IsnâÂÂt there a
*
missing?â nohillside
Jan 12 at 20:43
Yes I added the start and still the same issue
â alkabary
Jan 12 at 20:58
what exactly are you trying to do? disable ssh? better methods. kick off idle ssh connections? better methods. edit your question and tell us your end goal and we can give better help.
â ivanivan
Jan 12 at 23:04