user2373198 user2373198 - 2 months ago 9x
Linux Question

How to schedule jobs and passing arguments in linux and running in parallel

I want to run an script at a specific time at background. The job receive an input argument. In order to schedule a job, I found out that I should use the at command and run it like this:

at -f ./myjob now

and it works. However when I want to run it with an argument like this :

at -f ./myjob 1 now

it gives me the Garbled time error message. Does anyone have any idea how to solve the problem?

Update :
I want to run the job with different parameters in parallel. like this

at -f ./myjob 1 now

at -f ./myjob 2 now

at -f ./myjob 3 now


The at command has the -f file option which reads commands from a file rather than standard input. Therefore put your commands in a file, for example cmds, which would contain the following:

./myjob 1

To run multiple jobs in parallel use the ampersand operator to fork each job:

./myjob 1 &
./myjob 2 &
./myjob 3

Then run:

at -f ./cmds now

More information can be found by reading the at man page, via man at.