Send local files to remote
scp -r /Users/Jiachi/Desktop/RA_Prof.ChenNan/extracter.py zlab@nan.d2.comp.nus.edu.sg:/mnt/ssd2/home/zlab/users/Jiachi
Check this storm.cis.fordham.edu/~yli/documents/CISC2200Fall21/5_TransferFilesScpMac.pdf for more reference
Run Codes in the Background in Server
See SSH - Run Codes in the Background.
Q&A
-
Will the CSV Output Appear Automatically After the Scripts Finish?
- If each script is set up to save output directly to a
.csvfile (e.g., withpandas.to_csv("output.csv")), the files will be created automatically as long as the script completes successfully. You don’t need to do anything further, and the output files will be available on the server as soon as each script finishes. - If your scripts are instead printing output to the terminal, you won’t see that output directly in the
.csvfiles. To ensure the output goes to.csvfiles, make sure each script is saving the data directly within the code.
- If each script is set up to save output directly to a
-
Will the Scripts Stop Running If You Lose Connection with the Server?
- No, if you start each script within a
screensession and then detach the session (usingCtrl+A D), they will continue to run in the background, even if you disconnect from the server. screenis designed to keep sessions alive independently of your SSH connection, so you can log out without stopping the scripts.
- No, if you start each script within a
In short, once you set up each screen session to run and detach them, your scripts will run to completion and save their .csv output files without needing further intervention. You can reconnect to the server anytime to check on the files or reattach to the sessions if needed.
Kill Screen
To stop all screen sessions that are running your scripts, you can follow these steps:
-
List All Active Screen Sessions:
-
First, check all active screen sessions:
screen -ls
-
-
Terminate Each Session:
-
For each session you want to stop, use the following command to quit:
screen -S session_name -X quit -
Replace
session_namewith the name or ID shown in thescreen -lsoutput, likerace_fullorrace_last. -
For example:
screen -S race_full -X quit screen -S race_last -X quit
-
-
Kill All Screen Sessions at Once (Optional):
-
If you want to terminate all screen sessions at once, use:
screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill -
This command finds all detached sessions and kills them. Be careful, as this will stop all running
screenprocesses.
-
After running these commands, all the screen sessions running your scripts will be stopped, and the scripts will no longer be running in the background.
Copy from File from Folder A to Folder B
cp example.txt ~/Documents