#!bin/bash
chmod 777 {shell script}
a=7
echo "a is $a"
#!/bin/bash
a=7
echo "a is $a"
if [ "$a" -gt 5 ]
then
echo "a is greater than 5"
elif [ "$a" -gt 3 ]
then
echo "a is greater than 3"
else
echo "etc"
fi
#!/bin/bash
a=("abc" "def" "ghi")
for element in ${a[@]}
do
echo ${element}
done
pytest02.py 파일을 백그라운드로 실행하는 shell script
bashtest.sh 파일 작성
# bash 실행
#!/bin/bash
# 환경설정
source /home/ubuntu/.bashrc
source /home/ubuntu/.profile
# 가상환경 활성화
pyenv activate py3_11_9
# 폴더로 움직이기
cd /home/ubuntu/work
# python 파일 실행 (아래에서 백그라운드 실행되기 때문에 실행 안해도되긴함)
# python /home/ubuntu/work/pytest02.py
# 백그라운드 실행 및 리다이렉션
nohup python /home/ubuntu/work/pytest02.py > /home/ubuntu/work/print_txt.txt 2>&1 &
# 가상환경 풀기
pyenv deactivate
chmod 777 bashtest.sh