-
Notifications
You must be signed in to change notification settings - Fork 16
Miscellaneous Tips
AminaJLi edited this page Apr 16, 2023
·
26 revisions
Miscellaneous tips for Linux terminal:
- Most frequently used longer commands can be aliased to a shorter, easier-to-remember name by using
~/.bash_profileor~/.bashrc. Add a line withalias newcommand='<insert full command here>'to either. (You can also use aliasing to cover misspellings of common commands 👀). There is an example.bashrcfile copied from Pod with some aliases in theTutorialFilesfolder. -
nohup <insert full command here> > filename.out &is amazingly useful for interactive commands that take a while to run. (Notably, thehaddcommand to combine root files for training and testing subsets can take a while.)nohupstands for "no hangup" so your command will continue to run even if your ssh session times out. The output that would be typically printed to your terminal is saved infilename.outand the ampersand (&) works as it usually does, running the command in the background so you can continue to use the terminal. - Use
scp username@server.hostname:/path/to/remote/file .orscp /path/to/local/file username@server.hostname:/path/to/destinationto move files from your local storage to a remote server. The structure is similar to thecpcommand so a period can be used to stand for your current directory. For large files or many files, it's much better to use Globus. -
ls -F | grep -v / | wc -lwill show the number of files in a directory (not counting subdirectories). -
hadd final.root file1.root file2.rootwill merge file1 and file2 into a new rootfile. This command also works with wildcards so you can usehadd final.root filename_run*.rootto merge all rootfiles that start with "filename_run" into one. Not a Linux tip but a ROOT one -- a working install of ROOT is needed.
Miscellaneous tips for Docker:
- To use an environmental variable inside the container, add
-e YOURVARIABLE=valueto thedocker runcommand. For the LDMX framework, thedocker runcommand is bundled into the aliasldmx. Search theldmx-env.shfile fordocker runand you can add your variable there. Make sure to sourceldmx-env.shafter your changes.
Miscellaneous tips for Pod:
- The job files for slurm have many options that can be modified. (If you're using scripts to generate the job files, look in the script for the options so they apply to all job files.) Useful ones for keeping track of your jobs are
--mail-type=BEGIN,END,FAILand--mail-user=username@ucsb.eduwhich turn on email notifications. You will be emailed when your jobs begin running, finish, and/or fail. - Use the correct resource for your job length. If it's around an hour or less, you can run it interactively in the terminal. If it's a few hours (up to around 5 hours), you can use the short slurm queue with
sbatch -p short. Anything longer than that, you should submit to the usual slurm queue withsbatch. - You can check your queue of jobs with
squeue -u your_username. - If you notice an issue with one job in your queue, take note of the job ID and kill it with
scancel <JOB_ID>. - If your jobs begin failing or realize you've made a mistake, kill all your jobs with
scancel -u your_username. In theory, this is the same asscancel --mebut I like the safety of explicitly inputting my own username. - Environmental variables are automatically used with the version of singularity on Pod. You just need to set the variable with
export YOURVARIABLE=value.
Miscellaneous tips for SLAC:
- Don't forget to include the
-XYflag when logging in to SLAC! Without this, you won't be able to view the contents of ROOT files interactively through aTBrowser. - Use the
-jflag when doingldmx make installto expedite the process. A recommended setting is-j2, but you could go higher. Do keep the setting below-j10. - If you find that
treeMaker.pyisn't cooperating when you try to submit some batch jobs, it's probably because the container can't findcellmodule.txtorlibFramework.soor both. To get around this, open uptreeMaker.pyand change lines 7 and 8 so that they use absolute file paths. - Use the
bjobscommand to monitor the status of all of your batch jobs. Alternatively, usebpeek <JOB_ID>to closely monitor the output of the job with the specified job ID. - If you're submitting a particularly large batch job and you need more time/memory, use the
longqueue and increase-Wand-nappropriately. Do limit the number of cores you use to a reasonable amount. - If you absolutely must terminate all of your batch jobs, use
bkill 0. Alternatively, usebkill <JOB_ID>to just kill the job with the specified job ID.