Scheduling a Bash script with cron turns a command that already works in the terminal into a recurring background job. The important handoff is not only the time expression; cron also needs an executable script path, a shell, and enough environment to run without your interactive profile.
A per-user crontab is the safest starting point when the job should run as your own account. Each job line has five time fields followed by the command, and separate environment lines such as SHELL, PATH, and MAILTO can be placed above the schedule.
Cron starts jobs with a smaller environment than an interactive Bash session. Use absolute paths, put reusable logic in a script with a #!/bin/bash shebang, redirect output to a log you can inspect, treat schedule times as the host cron daemon's local time, and list the crontab after saving so the installed schedule is visible before the next run time arrives.
Related: How to create and run a Bash script
Related: How to list cron jobs in Linux
Related: How to remove a cron job in Linux
$ mkdir -p "$HOME/bin" $ vi "$HOME/bin/report.sh"
#!/bin/bash set -euo pipefail printf 'report completed: %s\n' "$(/usr/bin/date -Is)"
The script path can be different, but the crontab entry should use the full path instead of relying on the current working directory.
$ chmod u+x "$HOME/bin/report.sh" $ "$HOME/bin/report.sh" report completed: 2026-06-04T03:00:01+00:00
Fix script errors before adding the cron entry. Cron will not provide your interactive prompt, aliases, shell functions, or unsaved terminal variables.
# m h dom mon dow command 0 3 * * * /home/alice/bin/report.sh >> /home/alice/report.log 2>&1
The five fields are minute, hour, day of month, month, and day of week. This example runs the Bash script every day at 03:00 and appends standard output and errors to a log file.
Tool: Crontab Generator
$ crontab -e
Use sudo crontab -u username -e only when the scheduled script must run as a different account. The file edited with crontab -e is a user crontab, not /etc/crontab, so it does not include a username column.
SHELL=/bin/bash PATH=/usr/local/bin:/usr/bin:/bin MAILTO="" 0 3 * * * /home/alice/bin/report.sh >> /home/alice/report.log 2>&1
SHELL=/bin/bash makes cron run the command with Bash. Keep PATH explicit, and add any additional command directories your script needs.
If the cron command itself contains a % character, escape it as \%. Cron treats unescaped percent signs in the command field as line breaks passed to the command.
A normal Linux cron daemon reloads the saved user crontab automatically. A service restart is not usually required after crontab -e saves successfully.
$ crontab -l SHELL=/bin/bash PATH=/usr/local/bin:/usr/bin:/bin MAILTO="" 0 3 * * * /home/alice/bin/report.sh >> /home/alice/report.log 2>&1
This is the immediate success check for the scheduling change. If the job belongs to another account, list that account's crontab with sudo crontab -u username -l.
Related: How to list cron jobs in Linux
$ cat /home/alice/report.log report completed: 2026-06-04T03:00:01+00:00
A new line in the log confirms that cron matched the schedule, launched Bash, and ran the script under the account that owns the crontab.