Reputation: 43
I am currently trying to schedule a cronjob to run a script every minute.
I researched on how to do this, and most of them said to open a new terminal window and type crontab-l
. However, when I do this it doesn't do anything and it just goes to a new line, when its supposed to say something like "no crontab for root". Then I typed in crontab-e, but this gives me: this
I am not sure what to do now, as I cannot proceed with the instructions found on the internet.
Any help would be appreciated. Thanks!
Upvotes: 0
Views: 864
Reputation: 3060
First, to be clear to others reading this (I tried to edit the OP's post but I need to make six char change), the commands are crontab -l
and crontab -e
to list and edit respectively (note the space between the command and the flag following it, where the commands in UNIX use minus as a flag delimiter).
Had you run crontab -l you would have got nothing by default as you have no crontab set.
Run crontab -e will put you in a screen editor session, with crontab running whatever executable is configured in your $EDITOR variable which is vi by default. This is in your image clip.
I recommend learning vi. It's the default editor on most, if not every, UNIX/Linux install and worth learning. Here's a reasonable starting point for that.
To run the script every minute round the clock without any breaks, enter the following keystrokes into the crontab sessions:
i* * * * * /path/to/my/script<ESC>:x
which will enter insert mode with the leading 'i', enter
* * * * * /path/to/my/script
into the body of the file, then <ESC>
to go into command mode, and :x
to exit with saving.
crontab -l
will now show you the entry. If the script errors in some way, you will get UNIX mail in your system mail file. Use mailx to read the mail.
Upvotes: 1