crontab -e is not working
I am testing crobtab with a simple script which runs for every minute (pasted the temp.sh below), But it is not working
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /home/temp/temp.sh
temp.sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
echo $backup_dir >> $PWD/temp.txt
Permission details :
-rwxrwxrwx 1 temp temp 73 Mar 14 21:55 temp.sh
-rw-rw-r-- 1 temp temp 100 Mar 14 21:59 temp.txt
NOTE : when I run manually like "/home/temp/temp.sh", It is working and printing the date in temp.txt file
Anyhelp is appreciated. Thanks
LINUX : Ubuntu 18
bash permissions scripts cron
add a comment |
I am testing crobtab with a simple script which runs for every minute (pasted the temp.sh below), But it is not working
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /home/temp/temp.sh
temp.sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
echo $backup_dir >> $PWD/temp.txt
Permission details :
-rwxrwxrwx 1 temp temp 73 Mar 14 21:55 temp.sh
-rw-rw-r-- 1 temp temp 100 Mar 14 21:59 temp.txt
NOTE : when I run manually like "/home/temp/temp.sh", It is working and printing the date in temp.txt file
Anyhelp is appreciated. Thanks
LINUX : Ubuntu 18
bash permissions scripts cron
Try to add the shebang#!/bin/sh
as first line oftemp.sh
, Does/home/temp
is the home directory of the user that running the job?
– pa4080
Mar 14 at 17:18
add a comment |
I am testing crobtab with a simple script which runs for every minute (pasted the temp.sh below), But it is not working
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /home/temp/temp.sh
temp.sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
echo $backup_dir >> $PWD/temp.txt
Permission details :
-rwxrwxrwx 1 temp temp 73 Mar 14 21:55 temp.sh
-rw-rw-r-- 1 temp temp 100 Mar 14 21:59 temp.txt
NOTE : when I run manually like "/home/temp/temp.sh", It is working and printing the date in temp.txt file
Anyhelp is appreciated. Thanks
LINUX : Ubuntu 18
bash permissions scripts cron
I am testing crobtab with a simple script which runs for every minute (pasted the temp.sh below), But it is not working
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /home/temp/temp.sh
temp.sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
echo $backup_dir >> $PWD/temp.txt
Permission details :
-rwxrwxrwx 1 temp temp 73 Mar 14 21:55 temp.sh
-rw-rw-r-- 1 temp temp 100 Mar 14 21:59 temp.txt
NOTE : when I run manually like "/home/temp/temp.sh", It is working and printing the date in temp.txt file
Anyhelp is appreciated. Thanks
LINUX : Ubuntu 18
bash permissions scripts cron
bash permissions scripts cron
asked Mar 14 at 16:41
HarryHarry
1032
1032
Try to add the shebang#!/bin/sh
as first line oftemp.sh
, Does/home/temp
is the home directory of the user that running the job?
– pa4080
Mar 14 at 17:18
add a comment |
Try to add the shebang#!/bin/sh
as first line oftemp.sh
, Does/home/temp
is the home directory of the user that running the job?
– pa4080
Mar 14 at 17:18
Try to add the shebang
#!/bin/sh
as first line of temp.sh
, Does /home/temp
is the home directory of the user that running the job?– pa4080
Mar 14 at 17:18
Try to add the shebang
#!/bin/sh
as first line of temp.sh
, Does /home/temp
is the home directory of the user that running the job?– pa4080
Mar 14 at 17:18
add a comment |
2 Answers
2
active
oldest
votes
The crontab -e
file should be:
*/1 * * * * /home/temp/temp.sh
Make sure that temp.sh has execute permission to create temp.txt using chmod +x temp.sh
.
Also add shebang and cd to the output diirectory in the temp.sh file
#!/bin/sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
cd /home/temp/
echo $backup_dir >> $PWD/temp.txt
temp.sh is a executable file and added shebang didn't help, I only see the following entries in the /var/log/syslog I see the following log in the /var/log/syslog without any error for every one minute LOG : Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:31
did you add thecd /home/temp/
that I mentioned?
– GGJON
Mar 14 at 17:32
ya its working, what is the significance of cd command in this cron?
– Harry
Mar 14 at 17:36
1
Well, the default output directory is the user's home folder, which in your case should be/home/dominic/
(guessing from the cron log). So since you are logged in as dominic, the temp.txt file should have been generated in/home/dominic/
. Adding the cd just changed the$PWD
to this new directory
– GGJON
Mar 14 at 17:52
I modified the answer. I had it right, but lost track when the first * got read as bullets on stackoverflow.
– GGJON
Mar 14 at 18:54
|
show 1 more comment
Have you checked whether /etc/cron.allow
exists? In this case, user "temp" has to be listed in there. Apart from that, /var/log/syslog
should contain any related error/status messages.
/etc/cron.allow is not available
– Harry
Mar 14 at 17:20
Also I see the following log in the /var/log/syslog without any error for every one minute Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:21
The above log message tells you that cron is trying to execute the mentioned script in a subdirectory of "dominic"'s home directory every minute using the credentials of user "temp" (note the discrepancy dominic<>temp). This means that there has to be an entry in either "temp"'s crontab or in/etc/crontab
.
– Markus Ueberall
Mar 14 at 17:34
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1125661%2fcrontab-e-is-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The crontab -e
file should be:
*/1 * * * * /home/temp/temp.sh
Make sure that temp.sh has execute permission to create temp.txt using chmod +x temp.sh
.
Also add shebang and cd to the output diirectory in the temp.sh file
#!/bin/sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
cd /home/temp/
echo $backup_dir >> $PWD/temp.txt
temp.sh is a executable file and added shebang didn't help, I only see the following entries in the /var/log/syslog I see the following log in the /var/log/syslog without any error for every one minute LOG : Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:31
did you add thecd /home/temp/
that I mentioned?
– GGJON
Mar 14 at 17:32
ya its working, what is the significance of cd command in this cron?
– Harry
Mar 14 at 17:36
1
Well, the default output directory is the user's home folder, which in your case should be/home/dominic/
(guessing from the cron log). So since you are logged in as dominic, the temp.txt file should have been generated in/home/dominic/
. Adding the cd just changed the$PWD
to this new directory
– GGJON
Mar 14 at 17:52
I modified the answer. I had it right, but lost track when the first * got read as bullets on stackoverflow.
– GGJON
Mar 14 at 18:54
|
show 1 more comment
The crontab -e
file should be:
*/1 * * * * /home/temp/temp.sh
Make sure that temp.sh has execute permission to create temp.txt using chmod +x temp.sh
.
Also add shebang and cd to the output diirectory in the temp.sh file
#!/bin/sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
cd /home/temp/
echo $backup_dir >> $PWD/temp.txt
temp.sh is a executable file and added shebang didn't help, I only see the following entries in the /var/log/syslog I see the following log in the /var/log/syslog without any error for every one minute LOG : Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:31
did you add thecd /home/temp/
that I mentioned?
– GGJON
Mar 14 at 17:32
ya its working, what is the significance of cd command in this cron?
– Harry
Mar 14 at 17:36
1
Well, the default output directory is the user's home folder, which in your case should be/home/dominic/
(guessing from the cron log). So since you are logged in as dominic, the temp.txt file should have been generated in/home/dominic/
. Adding the cd just changed the$PWD
to this new directory
– GGJON
Mar 14 at 17:52
I modified the answer. I had it right, but lost track when the first * got read as bullets on stackoverflow.
– GGJON
Mar 14 at 18:54
|
show 1 more comment
The crontab -e
file should be:
*/1 * * * * /home/temp/temp.sh
Make sure that temp.sh has execute permission to create temp.txt using chmod +x temp.sh
.
Also add shebang and cd to the output diirectory in the temp.sh file
#!/bin/sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
cd /home/temp/
echo $backup_dir >> $PWD/temp.txt
The crontab -e
file should be:
*/1 * * * * /home/temp/temp.sh
Make sure that temp.sh has execute permission to create temp.txt using chmod +x temp.sh
.
Also add shebang and cd to the output diirectory in the temp.sh file
#!/bin/sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
cd /home/temp/
echo $backup_dir >> $PWD/temp.txt
edited Mar 14 at 18:49
answered Mar 14 at 17:10
GGJONGGJON
548
548
temp.sh is a executable file and added shebang didn't help, I only see the following entries in the /var/log/syslog I see the following log in the /var/log/syslog without any error for every one minute LOG : Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:31
did you add thecd /home/temp/
that I mentioned?
– GGJON
Mar 14 at 17:32
ya its working, what is the significance of cd command in this cron?
– Harry
Mar 14 at 17:36
1
Well, the default output directory is the user's home folder, which in your case should be/home/dominic/
(guessing from the cron log). So since you are logged in as dominic, the temp.txt file should have been generated in/home/dominic/
. Adding the cd just changed the$PWD
to this new directory
– GGJON
Mar 14 at 17:52
I modified the answer. I had it right, but lost track when the first * got read as bullets on stackoverflow.
– GGJON
Mar 14 at 18:54
|
show 1 more comment
temp.sh is a executable file and added shebang didn't help, I only see the following entries in the /var/log/syslog I see the following log in the /var/log/syslog without any error for every one minute LOG : Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:31
did you add thecd /home/temp/
that I mentioned?
– GGJON
Mar 14 at 17:32
ya its working, what is the significance of cd command in this cron?
– Harry
Mar 14 at 17:36
1
Well, the default output directory is the user's home folder, which in your case should be/home/dominic/
(guessing from the cron log). So since you are logged in as dominic, the temp.txt file should have been generated in/home/dominic/
. Adding the cd just changed the$PWD
to this new directory
– GGJON
Mar 14 at 17:52
I modified the answer. I had it right, but lost track when the first * got read as bullets on stackoverflow.
– GGJON
Mar 14 at 18:54
temp.sh is a executable file and added shebang didn't help, I only see the following entries in the /var/log/syslog I see the following log in the /var/log/syslog without any error for every one minute LOG : Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:31
temp.sh is a executable file and added shebang didn't help, I only see the following entries in the /var/log/syslog I see the following log in the /var/log/syslog without any error for every one minute LOG : Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:31
did you add the
cd /home/temp/
that I mentioned?– GGJON
Mar 14 at 17:32
did you add the
cd /home/temp/
that I mentioned?– GGJON
Mar 14 at 17:32
ya its working, what is the significance of cd command in this cron?
– Harry
Mar 14 at 17:36
ya its working, what is the significance of cd command in this cron?
– Harry
Mar 14 at 17:36
1
1
Well, the default output directory is the user's home folder, which in your case should be
/home/dominic/
(guessing from the cron log). So since you are logged in as dominic, the temp.txt file should have been generated in /home/dominic/
. Adding the cd just changed the $PWD
to this new directory– GGJON
Mar 14 at 17:52
Well, the default output directory is the user's home folder, which in your case should be
/home/dominic/
(guessing from the cron log). So since you are logged in as dominic, the temp.txt file should have been generated in /home/dominic/
. Adding the cd just changed the $PWD
to this new directory– GGJON
Mar 14 at 17:52
I modified the answer. I had it right, but lost track when the first * got read as bullets on stackoverflow.
– GGJON
Mar 14 at 18:54
I modified the answer. I had it right, but lost track when the first * got read as bullets on stackoverflow.
– GGJON
Mar 14 at 18:54
|
show 1 more comment
Have you checked whether /etc/cron.allow
exists? In this case, user "temp" has to be listed in there. Apart from that, /var/log/syslog
should contain any related error/status messages.
/etc/cron.allow is not available
– Harry
Mar 14 at 17:20
Also I see the following log in the /var/log/syslog without any error for every one minute Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:21
The above log message tells you that cron is trying to execute the mentioned script in a subdirectory of "dominic"'s home directory every minute using the credentials of user "temp" (note the discrepancy dominic<>temp). This means that there has to be an entry in either "temp"'s crontab or in/etc/crontab
.
– Markus Ueberall
Mar 14 at 17:34
add a comment |
Have you checked whether /etc/cron.allow
exists? In this case, user "temp" has to be listed in there. Apart from that, /var/log/syslog
should contain any related error/status messages.
/etc/cron.allow is not available
– Harry
Mar 14 at 17:20
Also I see the following log in the /var/log/syslog without any error for every one minute Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:21
The above log message tells you that cron is trying to execute the mentioned script in a subdirectory of "dominic"'s home directory every minute using the credentials of user "temp" (note the discrepancy dominic<>temp). This means that there has to be an entry in either "temp"'s crontab or in/etc/crontab
.
– Markus Ueberall
Mar 14 at 17:34
add a comment |
Have you checked whether /etc/cron.allow
exists? In this case, user "temp" has to be listed in there. Apart from that, /var/log/syslog
should contain any related error/status messages.
Have you checked whether /etc/cron.allow
exists? In this case, user "temp" has to be listed in there. Apart from that, /var/log/syslog
should contain any related error/status messages.
answered Mar 14 at 17:11
Markus UeberallMarkus Ueberall
1296
1296
/etc/cron.allow is not available
– Harry
Mar 14 at 17:20
Also I see the following log in the /var/log/syslog without any error for every one minute Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:21
The above log message tells you that cron is trying to execute the mentioned script in a subdirectory of "dominic"'s home directory every minute using the credentials of user "temp" (note the discrepancy dominic<>temp). This means that there has to be an entry in either "temp"'s crontab or in/etc/crontab
.
– Markus Ueberall
Mar 14 at 17:34
add a comment |
/etc/cron.allow is not available
– Harry
Mar 14 at 17:20
Also I see the following log in the /var/log/syslog without any error for every one minute Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:21
The above log message tells you that cron is trying to execute the mentioned script in a subdirectory of "dominic"'s home directory every minute using the credentials of user "temp" (note the discrepancy dominic<>temp). This means that there has to be an entry in either "temp"'s crontab or in/etc/crontab
.
– Markus Ueberall
Mar 14 at 17:34
/etc/cron.allow is not available
– Harry
Mar 14 at 17:20
/etc/cron.allow is not available
– Harry
Mar 14 at 17:20
Also I see the following log in the /var/log/syslog without any error for every one minute Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:21
Also I see the following log in the /var/log/syslog without any error for every one minute Mar 14 22:49:01 Host-Temp CRON[15277]: (temp) CMD (/home/dominic/finalewd/temp.sh) - I don't know the meaning of it
– Harry
Mar 14 at 17:21
The above log message tells you that cron is trying to execute the mentioned script in a subdirectory of "dominic"'s home directory every minute using the credentials of user "temp" (note the discrepancy dominic<>temp). This means that there has to be an entry in either "temp"'s crontab or in
/etc/crontab
.– Markus Ueberall
Mar 14 at 17:34
The above log message tells you that cron is trying to execute the mentioned script in a subdirectory of "dominic"'s home directory every minute using the credentials of user "temp" (note the discrepancy dominic<>temp). This means that there has to be an entry in either "temp"'s crontab or in
/etc/crontab
.– Markus Ueberall
Mar 14 at 17:34
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1125661%2fcrontab-e-is-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Try to add the shebang
#!/bin/sh
as first line oftemp.sh
, Does/home/temp
is the home directory of the user that running the job?– pa4080
Mar 14 at 17:18