I set up cron on the server at work. Write the information you need to a minimum.
** What I want to do: ** Run the Perl script `` `/foo/bar/baz.pl``` every morning at 5am ** Prerequisites: ** Linux for OS, bash for shell
What I did is as follows (excluding trial and error).
Log in to the server (Linux). Check the EDITOR environment variable.
$ echo $EDITOR
It was empty. If you try to edit crontab here, vi will start. I only know how to use Emacs. Try starting Emacs.
$ emacs
There is no such command Error message
It was no good. You can install Emacs, but I'll use nano here. nano is usually installed on Linux and is an editor that works even if you don't know how to use it.
$ EDITOR=nano
$ export EDITOR
$ echo $EDITOR
nano
I was able to set nano safely.
Try using the command `` `date``` to know the current time.
$ date
Fri Aug 14 08:43:43 UTC 2020
It turns out that it is UTC (the same as London time at the time of World Agreement). Check the time difference site to find out what time 5 am in Japan is in UTC.
https://www.jisakeisan.com/
It turned out to be 20:00.
Finally crontab settings.
-l
A list of crons that are currently set as an option.
$ crontab -l
Nothing came out so I knew no one had set anything.
Editing is the -e
option (Edit).
If you run it yourself (the logged-in user), you do not need to set the `` `-u``` option.
$ crontab -e
The nano set in $ EDITOR just started.
To run /foo/bar/baz.pl at 5am every morning:
0 20 * * * /foo/bar/baz.pl
You can use nano, but Ctrl + O writes out the file (write Out) and Ctrl + X exits nano (eXit). You don't have to remember how to use nano because it is displayed at the bottom of the screen.
that's all.
How to set up cron https://qiita.com/hikouki/items/e744b3a4d356d2af12cf
Creating and editing crontab files https://docs.oracle.com/cd/E19253-01/819-0379/sysrescron-24589/index.html
** (End of this section) **
Recommended Posts