get an error typeset: not found when i launch my script by crontab?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I use this portion of code to set default values in my config on my script.sh
typeset -A config # init array
config=( # set default values in config array
# chemin du dossier de log
[log]=$SCRIPTPATH"/logs"
# chemin du dossier local
[local]=""
)
when i launch my script with shell console everything is OK and working
But if I want to schedule launch with crontab i get an error
/var/********/script.sh: 148: /var/********/script.sh: typeset: not found
/var/********/script.sh: 149: /var/********/script.sh: Syntax error: "(" unexpected
here is my crontab line
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root /var/********/script.sh -c file.conf > /dev/null 2> /var/********/errors.log
can you explain me why ? thanks
shell-script cron error-handling typeset
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
I use this portion of code to set default values in my config on my script.sh
typeset -A config # init array
config=( # set default values in config array
# chemin du dossier de log
[log]=$SCRIPTPATH"/logs"
# chemin du dossier local
[local]=""
)
when i launch my script with shell console everything is OK and working
But if I want to schedule launch with crontab i get an error
/var/********/script.sh: 148: /var/********/script.sh: typeset: not found
/var/********/script.sh: 149: /var/********/script.sh: Syntax error: "(" unexpected
here is my crontab line
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root /var/********/script.sh -c file.conf > /dev/null 2> /var/********/errors.log
can you explain me why ? thanks
shell-script cron error-handling typeset
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
How is your cron job invoking the script? Does the script have a she-bang line?
â Jeff Schaller
15 mins ago
sorry, i've updated the post
â J.D
10 mins ago
i'm sorry but i don't know what is she-bang line... I'm a noob on shell scripting
â J.D
2 mins ago
Is that the entire script? Or is the first line something like#!/bin/sh?
â Jeff Schaller
11 secs ago
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use this portion of code to set default values in my config on my script.sh
typeset -A config # init array
config=( # set default values in config array
# chemin du dossier de log
[log]=$SCRIPTPATH"/logs"
# chemin du dossier local
[local]=""
)
when i launch my script with shell console everything is OK and working
But if I want to schedule launch with crontab i get an error
/var/********/script.sh: 148: /var/********/script.sh: typeset: not found
/var/********/script.sh: 149: /var/********/script.sh: Syntax error: "(" unexpected
here is my crontab line
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root /var/********/script.sh -c file.conf > /dev/null 2> /var/********/errors.log
can you explain me why ? thanks
shell-script cron error-handling typeset
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I use this portion of code to set default values in my config on my script.sh
typeset -A config # init array
config=( # set default values in config array
# chemin du dossier de log
[log]=$SCRIPTPATH"/logs"
# chemin du dossier local
[local]=""
)
when i launch my script with shell console everything is OK and working
But if I want to schedule launch with crontab i get an error
/var/********/script.sh: 148: /var/********/script.sh: typeset: not found
/var/********/script.sh: 149: /var/********/script.sh: Syntax error: "(" unexpected
here is my crontab line
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root /var/********/script.sh -c file.conf > /dev/null 2> /var/********/errors.log
can you explain me why ? thanks
shell-script cron error-handling typeset
shell-script cron error-handling typeset
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 11 mins ago
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 17 mins ago
J.D
112
112
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
J.D is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
How is your cron job invoking the script? Does the script have a she-bang line?
â Jeff Schaller
15 mins ago
sorry, i've updated the post
â J.D
10 mins ago
i'm sorry but i don't know what is she-bang line... I'm a noob on shell scripting
â J.D
2 mins ago
Is that the entire script? Or is the first line something like#!/bin/sh?
â Jeff Schaller
11 secs ago
add a comment |Â
1
How is your cron job invoking the script? Does the script have a she-bang line?
â Jeff Schaller
15 mins ago
sorry, i've updated the post
â J.D
10 mins ago
i'm sorry but i don't know what is she-bang line... I'm a noob on shell scripting
â J.D
2 mins ago
Is that the entire script? Or is the first line something like#!/bin/sh?
â Jeff Schaller
11 secs ago
1
1
How is your cron job invoking the script? Does the script have a she-bang line?
â Jeff Schaller
15 mins ago
How is your cron job invoking the script? Does the script have a she-bang line?
â Jeff Schaller
15 mins ago
sorry, i've updated the post
â J.D
10 mins ago
sorry, i've updated the post
â J.D
10 mins ago
i'm sorry but i don't know what is she-bang line... I'm a noob on shell scripting
â J.D
2 mins ago
i'm sorry but i don't know what is she-bang line... I'm a noob on shell scripting
â J.D
2 mins ago
Is that the entire script? Or is the first line something like
#!/bin/sh ?â Jeff Schaller
11 secs ago
Is that the entire script? Or is the first line something like
#!/bin/sh ?â Jeff Schaller
11 secs ago
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
J.D is a new contributor. Be nice, and check out our Code of Conduct.
J.D is a new contributor. Be nice, and check out our Code of Conduct.
J.D is a new contributor. Be nice, and check out our Code of Conduct.
J.D is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476575%2fget-an-error-typeset-not-found-when-i-launch-my-script-by-crontab%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
How is your cron job invoking the script? Does the script have a she-bang line?
â Jeff Schaller
15 mins ago
sorry, i've updated the post
â J.D
10 mins ago
i'm sorry but i don't know what is she-bang line... I'm a noob on shell scripting
â J.D
2 mins ago
Is that the entire script? Or is the first line something like
#!/bin/sh?â Jeff Schaller
11 secs ago