Home > OS >  How to run sacct command in shell script
How to run sacct command in shell script

Time:12-02

I am trying to write a cron that will run sacct command of slurm for given dates and save it in file. As I don't have much experience with shell script I am not sure how to do it.

I did the following: I created a shell script with the following code (sacct_data.sh):

#!/bin/bash
startdate=`date  "%Y-%m-%dT00:00:00"`
enddate=`date -d "yesterday" ' %Y-%m-%dT00:00:00'`

TZ=UTC sacct info_that_needs_to_be_pulled --starttime $startdate --endtime $enddate > data.log

In the crontab I have the following code:

* * * * * bash sacct_data.sh #I know this will run every min, but that's is not important

However, I am getting the error "sacct: command not found".

Any help is appreciated :)

CodePudding user response:

The sacct: command not found error means that the command was not found in the PATH. And that is expected as the PATH set in cron environments is really minimal. You can either set a correct PATH variable (see this for instance) or use the absolute sacct path: type which sacct and use the output in sacct_data.sh.

  • Related