bash Flashcards

1
Q

bash: To run multiple command line commands consecutively until one fails, type

A

python file1.py (double ampersand) python file2.py && clear

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

bash: To connect to an irc channel in the terminal, use

A

telnet

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

bash: In mkdir my_file (double ampersand) cd $_ the $_ is

A

a reference to the last argument in the previous command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

bash: to set up a cron job

A

type crontab -e to edit your cron table
type crontab -l to list your current crontab entries

minute hour day-of-month month day-of-week command

notes:
cron jobs run from root directory, so to run them from specific directory, you can cd into it first by adding that to the command,
* * * * * cd /Users/mayaworsoff/desktop/instavid && /users/mayaworsoff/desktop/bin/python3 /users/mayaworsoff/desktop/scripts/instavid/instavid.py

That whole line after the * * * * * is just one command. Instead of writing python3 to run the script, I use the full path so it’s the interpreter from the correct virtual environment.
crontab stands for cron table
Use * for wildcard
Each user only gets one crontab
To run a python script first give path to interpreter, then to the script, ie
*/10 * * * * /usr/bin/python script.py
crontab runs automatically as soon as it is saved, no need to run anything

Example of local_crontab file where the script relies on libraries only downloaded in a specific virtual environment.
# This files is where I will save crontab schedules belonging to just this project
# Since each user only gets one crontab, I will need to concat this file into the main
# file by going:
# cat crontab1 crontab2 crontab3 > main-crontab
# crontab main-crontab # This registers the specified crontab to the user
# eg */10 * * * * /usr/bin/python script.py
* * * * * /users/mayaworsoff/desktop/scripts/notes_env/bin/python /users/mayaworsoff/desktop/scripts/notes_env/instavid/script.py
How well did you know this?
1
Not at all
2
3
4
5
Perfectly