The error “crontab: no crontab for user using an empty one” occurs when you try to edit the crontab file of a user that doesn’t have a crontab file yet. The solution is to create a new crontab file for the user:
- Open a terminal window.
- Run the following command to create a new crontab file for the current user:
crontab -e
- The crontab editor will open. If you’re creating a new crontab file, it will be empty.
- Add your cron jobs to the file in the following format:
* * * * * command
- Each field represents a different aspect of the schedule:
- minute (0-59)
- hour (0-23)
- day of the month (1-31)
- month (1-12)
- day of the week (0-7, where both 0 and 7 represent Sunday)
- For example, the following cron job will run the command
ls -l
every day at midnight:
0 0 * * * ls -l
- Save the file and exit the editor.
- The new crontab file will be installed and the cron job(s) will start running at the specified intervals.
Note: If you want to edit an existing crontab file, simply run the same command as above: crontab -e
.