Modify output file of sbatch - slurm

I have a job that has a long job-name, and in the .out file, it doesn't show the full name. How can I make it to print the full job-name in the .out file?

Related

Query of the execution step of shell command `ls > list`

root#VM-0-11-debian:~/linux/2023/01# ls
root#VM-0-11-debian:~/linux/2023/01# ls > list
root#VM-0-11-debian:~/linux/2023/01# ls
list
root#VM-0-11-debian:~/linux/2023/01# cat list
list
I know that > will redirect stdout to file. it will create the file if not present, otherwise replace it.
I would like to ask that is the shell command ls > list implementation process as I described below?
1)As the file named list not exists, so create a file named list first.
2)ls command will list the directory content(list). the content listed(list) will be in the standard output.
3)Add the content of the standard output(list) to the file named list in a replaced way.
My personal understanding of the implementation process as described above, I hope you can give me some guidance. Thank you.
The file redirection operator > is handled by your shell and any file to which you write will be created/truncated before the binary is started. That's why you can see the file name list in the content of the file: the file has already been created before the ls process was started.
So yes, your understanding is correct.
This is why it is not possible to do something like sort txt > txt – the file txt will be truncated before sort reads it. You will end up with an empty file.

Zip compress without root folders

My problem is that I have to generate a zip file using the linux zip console command. My command is as follows:
zip -r /folder1/folder2/EXP_45.zip /folder1/folder2/EXP_45/
That returns a correct zip only that includes the root folders I want:
Returns
EXP_45.zip
-folder1
--folder2
---EXP_45
...
I want
EXP_45.zip
-EXP_45
...
EXP_45 is a folder that can contain files and folders and they must be present in the zip. I just want the tree structure to start with the EXP_45 folder.
Is there any solution?
The reason why I need it to be a single command is that it is an action of a job in a PL SQL function like:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
JOB_NAME=>'compress_files', --- job name
JOB_ACTION=>'/usr/bin/zip', --- executable file with path
JOB_TYPE=>'executable', ----- job type
NUMBER_OF_ARGUMENTS=>4, -- parameters in numbers
AUTO_DROP =>false,
CREDENTIAL_NAME=>'credentials' -- give credentials name which you have created before "credintial"
);
dbms_scheduler.set_job_argument_value('compress_files',1,'-r');
dbms_scheduler.set_job_argument_value('compress_files',2,'-m');
dbms_scheduler.set_job_argument_value('compress_files',3,'/folder1/folder2/EXP_45.zip');
dbms_scheduler.set_job_argument_value('compress_files',4,'/folder1/folder2/EXP_45/');
DBMS_SCHEDULER.RUN_JOB('compress_files');
END;
I haven't been able to find a solution to this problem using zip but I have found it using jar. The command would be:
jar cMf /folder1/folder2/EXP_45.zip -C /folder1/folder2/EXP_45 .
Also, the solution using a job in pl sql in case it works for someone would be:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
JOB_NAME=>'compress_files', --- job name
JOB_ACTION=>'/usr/bin/jar', --- executable file with path
JOB_TYPE=>'executable', ----- job type
NUMBER_OF_ARGUMENTS=>5, -- parameters in numbers
AUTO_DROP =>false,
CREDENTIAL_NAME=>'credentials' -- give credentials name which you have created before "credintial"
);
dbms_scheduler.set_job_argument_value('compress_files',1,'cMf');
dbms_scheduler.set_job_argument_value('compress_files',2,'/folder1/folder2/EXP_45.zip');
dbms_scheduler.set_job_argument_value('compress_files',3,'-C');
dbms_scheduler.set_job_argument_value('compress_files',4,'/folder1/folder2/EXP_45');
dbms_scheduler.set_job_argument_value('compress_files',5,'.');
DBMS_SCHEDULER.RUN_JOB('compress_files');
END;
You want to use the -j (or --junk-paths) option when you are creating the zip file. Below is from the zip man page.
-j
--junk-paths
Store just the name of a saved file (junk the path), and do not store directory names.
By default, zip will store the full path (relative to the current directory).
Update following Question Clarification
Why not put the equivalent to the code below in a shell script & get the SQL function to invoke that? You just need to pass the directory name to cd into and the name of the output zip.
cd folder1/folder2
zip -r /tmp/EXP_45.zip EXP_45

write all statements that user execute it during a session

I have this question.
(Write "your_username.sh" script to create a text file each time you log out. The file should
contain all statements you execute during your session. The name of the text file should have the following naming pattern “Statements-20191104.0225.txt” (20191104
represents the date and 0225 represents the time). All files should be stored in the
~/MyStatements directory.)
I create sh script and call it inside .bash_logout.
This script creates a file and tries to save all history inside it
#!/bin/bash
currentDateTime=$(date +"%Y%m%d.%k%M")
fileName="Statements-$currentDateTime"
touch ~/MyStatements/$fileName
echo $currentDateTime
echo $fileName
history -a "~/MyStatements/$fileName"
history -a newFile.text
A new file created inside "MyStatements" folder but this file doesn't contain any data
Try to redirect your output:
history -a > ~/MyStatements/$fileName
history -a > newFile.text
See Redirect all output to file

Appending the text of a file

I am using Shell scripting. I tried the below option.
I want to append the part of a file to another part of a file.
I tried this command to append the content of a file.
Command:
/bin/cat ../../../test_op.txt/sql/part_code.txt >> ../../../PartitioningUtility/log/test_op.txt
To append the text of part_code.txt to test_op.txt.
No errors but the text is not appending.
Any Solution to this problem.
Any other option to append the data of a one file to another
If you want to append all content from '/bin/cat ../../../test_op.txt/sql/part_code.txt' to '../../../PartitioningUtility/log/test_op.txt' you could add 'cat' in the beginning:
cat ../../../test_op.txt/sql/part_code.txt >> ../../../PartitioningUtility/log/test_op.txt
That is assuming that file paths are correct.

(bash) how to add some iteraion to filename

I have the script that creates some .html and .txt files every day. But now it is only one file html and txt with changed content, I need every day a new html&txt file with date oof creation in the file name like : index_22-05-2013.html , i have these variables in shell script:
DESTINATION_HTML="./daily/html/index_$(date +"%F").html"
DESTINATION_TXT="./daily/txt/index_$(date +"%F").txt"
and a line in shell script that running one python script and creates html file
python `somescript.py` -m ${FILELIST[0]} ${FILELIST[1]} > $DESTINATION_HTML
and i`m getting this file created:
index_$(date +"%F").html
what i must to do to get this file name : index_22-05-2013.html
Sorry, I am not following you, but since
echo "index_$(date +%F).html"
outputs index_2013-08-20.html instead of index_22-05-2013.html which is what you need, you probably want to use this command instead:
echo "index_$(date +%d-%m-%Y).html"
Hope it helps! :)

Resources