I often use time
to time a command via console:
time PGPASSWORD=postgres psql -U postgres -h localhost -f init.sql
I now created a shell script which does the same:
#!/bin/sh
time PGPASSWORD=postgres psql -U postgres -h localhost -f init.sql
Now I get the following error:
time: cannot run PGPASSWORD=postgres: No such file or directory
Command exited with non-zero status 127
How can I use time
in a script?
bash
defines time
as a pre-command modifier; /bin/sh
is just running the external command time
. You probably want #!/bin/bash
as your shebang.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.