Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to create a cron entry with bash where the user only have to enter the command to execute and the script does the rest.

Create cron file if it isn't already created Set the execution time.

Thank you to investigate.

share|improve this question
Create empty temp file, launch editor and upon save you process the contents and create cron entry. – Jack Jun 19 '13 at 10:21

You could do:

crontab -l > ./my.cron
: manipulate ./my.cron somehow without editing
crontab ./my.cron     

I'm not aware of a tool that is a "wizard" for creating cron entries.

If your question is really about using nano, then set your VISUAL environment variable to your preferred editor.

share|improve this answer

I don't understand what you want. The normal way of creating a crontab is to run crontab -e. Then, the user will "only have to enter the command to execute and the script does the rest". All the user has to do is set the time and the command to be run. How could it be simpler?

It is impossible to have cron set the time automatically, how can it know when you would like the command to run? Do you mean you want to create a crontab that has a default time? If so, you could do something like this:

#!/usr/bin/env bash

time="0 5 * * 1" ## 5 a.m every week 

read -p "Enter the command you wish cron to run:" comm 

file=`mktemp` && echo "$time $comm" > $file && crontab $file && rm $file

You can save that as, for example, /usr/local/bin/

Alternatively, if all you want is to not use nano, change your $EDITOR variable. Personally I use emacs so I have this line in my .bashrc:

export EDITOR='/usr/bin/emacs';
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.