Skip to content

Commit

Permalink
[ DOC ]: Add additional notes for comamnds and django commands
Browse files Browse the repository at this point in the history
  • Loading branch information
a1eksb committed Jul 12, 2024
1 parent 1ba769e commit fe1682e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/docs/dev_notes/.pages
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nav:
- index.md
- linux.md
- django.md
16 changes: 16 additions & 0 deletions docs/docs/dev_notes/django.md
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
```

49 changes: 39 additions & 10 deletions docs/docs/dev_notes/linux.md
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")

0 comments on commit fe1682e

Please sign in to comment.