-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ DOC ]: Add additional notes for comamnds and django commands
- Loading branch information
Showing
3 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
nav: | ||
- index.md | ||
- linux.md | ||
- django.md |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: Django | ||
--- | ||
|
||
# Useful Django Commands | ||
|
||
**Creating migrations** | ||
```bash linenums="1" | ||
python manage.py makemigrations | ||
``` | ||
|
||
**Applying migrations** | ||
```bash linenums="1" | ||
python manage.py migrate | ||
``` | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,61 @@ | ||
--- | ||
title: Linux Commands | ||
title: Commands | ||
--- | ||
|
||
# Useful Linux Commands | ||
# Useful Commands | ||
|
||
This is a collection of useful linux commands that can be easily copy pasted. | ||
|
||
#### CRON | ||
The cron command-line utility is a job scheduler on Unix-like operating systems [^1]. It can be used to periodically run various scripts on your server. A detailed CRON guide is provide by [DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-ubuntu-1804). A helpful utility for understanding the cron time settings can be found on the following link: [https://crontab.guru](https://crontab.guru) | ||
#### GIT | ||
|
||
!!! note | ||
**View all remotes** | ||
```bash linenums="1" | ||
git remote -v | ||
``` | ||
|
||
In some environments you may need to setup environment variables such as the `PATH` and the `DOCKER_HOST`. This will enable your cron scripts to access and interact with services such as docker. | ||
**Change remote URL of specific remote** | ||
```bash linenums="1" | ||
git remote set-url remote_name new_url | ||
``` | ||
This can be useful if you for example moved your repository to a new domain / git platform or if you want to change the way you interact with a repository (e.g. change from ssh to https). | ||
|
||
**Add a new remote** | ||
```bash linenums="1" | ||
git remote add remote_name https://my.gitlab.instance/user/project.git | ||
``` | ||
In some cases you may wish to add a second remote. For example in cases where your code is stored on multiple git platforms that you wish to keep in sync. | ||
|
||
**Push to a specific remote** | ||
```bash linenums="1" | ||
git push -u -f remote_name | ||
``` | ||
|
||
#### CRON | ||
The cron command-line utility is a job scheduler on Unix-like operating systems [^1]. It can be used to periodically run various scripts on your server. A detailed CRON guide is provide by [DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-ubuntu-1804). A helpful utility for understanding the cron time settings can be found on the following link: [https://crontab.guru](https://crontab.guru) | ||
|
||
Editing the crontab of the current user: | ||
**Editing the crontab of the current user:** | ||
```bash linenums="1" | ||
crontab -e | ||
``` | ||
|
||
Erasing the crontab of the current user: | ||
**Erasing the crontab of the current user:** | ||
```bash linenums="1" | ||
crontab -r | ||
``` | ||
|
||
Storing the output of a cron job to a log file: | ||
**Storing the output of a cron job to a log file:** | ||
```bash linenums="1" | ||
your_cron_command >> /path/to/cron_output.log 2>&1 | ||
*/1 * * * * bash /path/to/your/command_or_script >> /path/to/cron_output.log 2>&1 | ||
``` | ||
|
||
!!! info | ||
|
||
In some environments you may need to setup environment variables such as the `PATH` and the `DOCKER_HOST`. This will enable your cron scripts to access and interact with services such as docker. | ||
|
||
|
||
!!! tip | ||
|
||
Ensure that you terminate commands with new lines and escape percentage signs using a backslash `\%` as this may cause issues if it is not done. | ||
|
||
|
||
[^1]: [https://en.wikipedia.org/wiki/Cron](https://en.wikipedia.org/wiki/Cron "Link to wikipedia CRON page") |