Autosys: Change directory before executing job - autosys

I'm new to Autosys and I'm using the WCC front end in order to run autosys jobs. I also have access to the terminal if the answer proves to only work in the terminal
I was wondering how to change the directory before running a job. At the moment, Autosys searches its root directory for a batch file buit I want it to point to C:/scripts. IS there any way to define this as the starting directory or am i stuck leaving script files in the root directory of Autosys?
Thank you for your help.

Full path to the script should stand in the "command" section, e.g.:
insert_job: my_job job_type: c
command: C\:\Scripts\script1.bat
machine: appserver.domain.com
Alternative solution is to add C:\Scripts to the PATH variable on your app server.

Related

How to save output when running job on cluster using SLURM

I want to run an R script using SLURM. I have created the R script, "test.R" as shown:
print("Running the test script")
write.csv(head(mtcars), "mtcars_data_test.csv")
I created a bash script to run this R script "submit.sh"
#!/bin/bash
#sbatch --job-name=test.job
#sbatch --output=.out/abc.out
Rscript /home/abc/job_sub_test/test.R
And I submitted the job on the cluster
sbatch submit.sh
I am not sure where my output is saved. I looked in the home directory but no output file.
Edit
I also set my working directory in test.R, but nothing different.
setwd("/home/abc")
print("Running the test script")
write.csv(head(mtcars), "mtcars_data_test.csv")
When I run the script without SLURM Rscript test.R, it worked fine and saved the output according to the set path.
Slurm will set the job working directory to the directory which was the working directory when the sbatch command was issued.
Assuming the /home directory is mounted on all compute nodes, you can change explicitly the working directory with cd in the submission script, or setwd() in the R syntax. But that should not be necessary.
Three possibilities:
either the job did not start at all because of a configuration or hardware issue ; that you can find out with the sacct command, looking at the state column.
either the file was indeed created but on the compute node on a filesystem that is not shared; in that case the best option is to SSH to the compute node (which you can find out with sacct) and look for the file there; or
the script crashed and the file was not created at all, in that case you should look into the output file of the job (.out/abc.out). Beware that the .out directory must be present before the job starts, and that, as it starts with a ., it will be a hidden file, revealed in ls only with the -a argument.
The --output argument to sbatch is relative to the folder you submitted the job from. setwd inside the R script wouldn't affect it, because Slurm has already parsed that argument and started piping output to the file by the time the R script is running.
First, if you want the output to go to /home/abc/.out/ make sure you're in your homedir when you submit the script, or specify the full path to the --output argument.
Second, the .out folder has to exist; I tested this and Slurm does not create it if it doesn't.

Short cut for invoking shell script in unix

I have below two file to start and stop my spring-boot application. Is it possible to have this installed as server etc in unix? so that I can just type start app or stop app to start or stop my application from any location?
startApplication.sh
stopApplication.sh
You can always define alias in your bash, do as below:
sudo vim ~/.bashrc
go at the end of file and add this line
alias start-app='bash /<path-to-script>/startApplications.sh'
save and exit and resource it with source command
source ~/.bashrc
now if you type in your terminal start-app it will execute your script. create one for stop-app too.

Rstudio Server Run from specific directory

I am spinning up an instance of rstudio server and I need the working directory of R to be a specific directory. I would also like the file pane in the bottom right corner to be pointing to the same directory. Is there a way to do this? Currently it runs from the home directory of whichever user is running the program. I have tried the --server-working-dir flag, and it does not seem to work. Here is the command I am using:
/usr/lib/rstudio-server/bin/rserver \
--server-daemonize=0 \
--server-user=user \
--server-working-dir=/some/path \
--auth-none=1 \
--auth-minimum-user-id=0
Any help would be useful here.
[edit] Just wanted to clarify that I would like the server to start in this directory. I am building a container that will be deployed multiple times, and I don't want the users to have to set their directories every time it is deployed.
If you want to modify the file pane in the right, you should edit /etc/rstudio/rsession.conf.
And add two lines in below:
session-default-working-dir=/some/path
session-default-new-project-dir=/some/path
You can do this by edditing the (global) R profile startup script. Here's a step by step guide:
1) Run Rscript -e "R.home()" -- this will tell you the location of your R directory home. In my case (Mac) it is /Library/Frameworks/R.framework/Resources
2) Go to /Library/Frameworks/R.framework/Resources/etc -- e.g., $R_HOME/etc
3) sudo touch Rprofile.site if it doesn't exist, then sudo nano Rprofile.site
4) Add the following lines and save:
cat("hi\n")
setwd("/some/path/")
You should avoid overwriting the users home directory.
Amongs the [.Rprofile] files you should only edit the Rprofile.site as a last resort since it acts globally.
Suggested solution:
R read the "initialization file" at start, in the following order:
.Rprofile.site
.Rprofile (located in the current directory).
.Rprofile (in the users home directory).
In your case if you are planning to login to R-Studio server you will end up in the users home directory, so I would suggest you to just edit the [.Rprofile] in the home directory. In case the [.Rprofile] is missing you need to create it.
Add this line in your .Rprofile [in your home directory]:
setwd ('/your/path/')
Logout/login to your R-studio server session and you will notice that the "file pane to the right location" has changed accordingly to what you specified in your .Rprofile.

Dokku .profile.d folder, scripts not executing

I cannot get bash scripts to run in the .profile.d folder. This seems like it should be very straight forward but I'm not having any luck.
I have a .profile.d folder in the root of my application. In it I have one script which builds ffmpeg from source called:
ffmpeg.sh
This script executes fine when I run it in the container and makes / installs ffmpeg. I've tried chmod +x and adding a #!/bin/bash to the top of the file.
I feel like I'm missing a basic understanding somewhere here, any tips?
Ok, this was running correctly, it just didn't output echo statements. I only found it by attaching to the running docker container after the deploy had finished.

Update current working directory after vim netrw exit

Here's the scenario.
I am on the unix command line (in home directory). I want to browse the directory through
$ vim .
thus opening the vim netrw.
Now I am browsing the directory using the netrw.
What I want here is that when I exit vim netwr, I want my previous current working directory (in this example the home directory) to now become the directory I was previously in vim netrw.
Example:
step 1. now in home directory
step 2. vim . (thus opening vim netrw)
step 3. go to any directory (~/my/other/folders)
step 4. :q (to exit vim)
step 5. (here, I want my previous directory to now become ~/my/other/folders
any ideas on how to do it? I was thinking of doing something in .vimrc but I dunno how. Been into google search, but found nothing valuable.
A possible solution would be to change the current work directory while in netrw by pressing c, and spawn a new shell from the folder you're in by issuing :shell
So it would look like:
vim .
Navigate to the desired folder...
c
:shell
And there you are in a shell in the current folder you were in netrw.
And when you exit that shell, you fall back to where you were in netrw and can continue using the explorer.
I don't think it's possible at all. Every command executed via system('command') or :!command is executed through a subshell, not through the shell that started Vim so I don't see how you could alter the host shell in any way.
But I smell an XY problem here. What is your goal?
Do you want to be able to execute some commands on the files you just edited and you want to be in their directory? If so, do you know about :sh? :!command?
Do you want a "graphical" file explorer for your shell? If so, do you know vifm? Ranger? Midnight Commander?
To add to Wadih's answer, you can put this in your .vimrc file:
let g:netrw_keepdir=0
This means the working directory will be automatically updated and you don't need to press c each time.
So after navigating to a folder in netrw, all you need to do is do this:
:sh
And this opens the terminal in the current folder.
From the netrw help file:
By default, g:netrw_keepdir is 1. This setting means that the current
directory will not track the browsing directory. (done for backwards
compatibility with v6's file explorer).
Setting g:netrw_keepdir to 0 tells netrw to make vim's current directory
track netrw's browsing directory.

Resources