-
-
Save alexey-kar/67f6fa61f8d72f3db4854b22f8622bd3 to your computer and use it in GitHub Desktop.
supervisor and cron commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################### | |
Supervisor | |
######################### | |
First install supervisor | |
apt install supervisor | |
Create a program then give permission to program | |
chmod +x <program_path> | |
The program configuration files for Supervisor programs are found | |
in the /etc/supervisor/conf.d directory | |
create conf file for your program | |
/etc/supervisor/conf.d/<new_file>.conf | |
add the following details | |
[program:<give_a_name>] | |
command=<program_path> | |
autostart=true | |
autorestart=true | |
stderr_logfile=<log_file_path_1> | |
stdout_logfile=<log_file_path_2> | |
For example | |
log_file_path_1 can be /var/log/long.err.log | |
Now run the following commands | |
supervisorctl reread | |
supervisorctl update | |
Now supervisor will start supervising the configured program | |
You can enter interactive shell by typing | |
supervisorctl | |
start all configuration | |
supervisorctl start all | |
stop all configuration | |
supervisorctl stop all | |
######################### | |
Cron | |
######################### | |
First install cron | |
apt install cron | |
To edit crontab | |
crontab -e | |
To view the crontab | |
crontab -l | |
To remove the crontab | |
crontab -r | |
* * * * * <file_path> 1>/dev/null 2>&1 | |
minute | |
hour | |
day of the month | |
month | |
day of the week | |
@hourly - Shorthand for 0 * * * * | |
@daily - Shorthand for 0 0 * * * | |
@weekly - Shorthand for 0 0 * * 0 | |
@monthly - Shorthand for 0 0 1 * * | |
@yearly - Shorthand for 0 0 1 1 * | |
@reboot, which runs the command once at startup. | |
* any value | |
, value list separator | |
- range of values | |
/ step values | |
To run command everyday at 9pm (21:00) | |
0 21 * * * sample.sh 1>/dev/null 2>&1 | |
To run sample.sh every Tuesday to Saturday at 1am (01:00) | |
0 1 * * 2-7 command 1>/dev/null 2>&1 | |
To run sample.sh at 07:30, 09:30 13:30 and 15:30 | |
30 07,09,13,15 * * * sample.sh | |
The files for each user are located at /var/spool/cron/crontab, | |
but they are not supposed to be edited directly. | |
Instead, it's best to use the crontab command. | |
################day of week vs day of month################# | |
Going back a step further from Vixie cron, the "wday OR mday" | |
logic was present in System V cron, but not System III or anything earlier. | |
Before Paul Vixie wrote his cron replacement, BSD cron was like the | |
SysIII-and-earlier cron. All 5 fields were ANDed. The post-4.4 BSDs | |
adopted Vixie cron, making themselves more SysV-like. | |
So don't ask (blame) Vixie. He was just cloning SysV. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment