[Linux] How do I create scheduled tasks with cron?
Posted: 25 Nov 2020, 10:04
cron is a standard Linux tool that is in charge of running scheduled tasks.
Write your script:
Write a bash script that performs your tasks and make it executable:
Configure cron to call your script:
Edit crontab:
Run nightly.sh every day at 04:00 in the morning:
You may need to restart your machine (or just the cron service) for changes to take effect.
Keep your crontab simple! DO use the absolute path to the executable. DO redirect standard output and error output, so you can see what the log says later.
Write your script:
Write a bash script that performs your tasks and make it executable:
Shell: Select all
vi nightly.sh
Shell: Select all
#!/bin/sh
filebot -script fn:amc --output "/path/to/output" --action duplicate -non-strict "/path/to/input" --log-file amc.log --def excludeList=amc.txt
Shell: Select all
chmod +x nightly.sh
Configure cron to call your script:
Edit crontab:
Shell: Select all
vi /etc/config/crontab
Shell: Select all
0 4 * * * /path/to/nightly.sh > /path/to/nightly.log 2>&1

