I will write an article on Qiita for the first time. I am always indebted to everyone who writes articles for Qiita. Thank you very much.
I think that when I was touching cron on Linux, I almost erased cron. (Some people have erased it ...)
what to do when it is erased, it is
what to do when you erase it, the ancestors are thinking about various countermeasures, so please check that.
Be sure to add the
-i option to the crontab command.
I think that there are many things to do directly. (Recently, it's been said that if you edit directly, you can't go into the server directly, but it's not all that wonderful environment.)
I'm thrilled when I do
-e when the option is specified.
This guy is on the right side of the keyboard.
As you know, if you do
crontab -r, all cron will disappear.
In the first place, there is a feeling that the option of the keyboard layout is specified as to why an accident should occur, but the reality is that.
If you run
man cron tab (cron description) on the linux command line, it says something like this in English.
-i This option modifies the -r option to prompt the user for a 'y/Y' response before actually removing the crontab.
I don't understand English a little,
-i option-If you do not answer y or Y before deleting cron with the r option, it will not be deleted
Something like that is written. This guy can be used.
I'll give it a try. (Do not test in production even if you make a mistake)
$ crontab -ir crontab: really delete hogehoge's crontab?
The hogehoge part is the user name.
After that, it is safe if you can exit with "Yabe" and
ctrl + c.
If you press
Y, cron disappears, but I don't know if you do that.
If you press it, it's OK. Even if you accidentally press the terrifying key to the right
It's safe because it will be heard at.
But it's not smart. It's rather annoying.
In the first place, there seems to be no problem with
(In the case of
-l, even if you write
-il, you will not be asked "Are you sure you want to erase it?")
Linux has an alias. Please check another site for details. I immediately read it in romaji and remembered a baseball player (I'm a fan of the Kanagawa baseball team).
In this example
alias crontab='crontab -i'
If you run
crontab, you've done crontab -i
It means that we were able to declare.
Then where do you declare this guy?
I have set it to
~ / .bash_profile.
If you write it here, it will be executed automatically when you log in to the black screen with ssh.
There is also a
~ / .bashrc, and even if you write it here, it will be executed without permission.
Which one to write depends on the individual's judgment.
Here's why I wrote it in
~ / .bash_profile:
When you execute
man bash (description of bash)
~/.bash_profile The personal initialization file, executed for login shells ~/.bashrc The individual per-interactive-shell startup file
It is written. I don't translate. This time
So I decided to add it to
~ / .bash_profile.
Here's what to do:
Add ʻalias crontab ='crontab -i'
to~ / .bash_profile`
(Settings are required for each user)
We are not responsible for anything that happens, so please test it.
Reduce the amount of time you get excited about cron.