Cron runs only once instead every minute
I'm trying to run a script every minute (on a Docker container running Ubuntu 16.04)
The /etc/echo.sh
simply echo the word "hi"
cat /etc/crontab
* * * * * root /etc/echo.sh > /var/log/cron.log 2>&1
/etc/init.d/cron reload
* Reloading configuration files for periodic command scheduler cron [ OK ]
tail -f /var/log/cron.log
hi
After printing "hi" once, nothing happens anymore.
Any ideas why?
cron docker ubuntu-16.04 crontab
add a comment |
I'm trying to run a script every minute (on a Docker container running Ubuntu 16.04)
The /etc/echo.sh
simply echo the word "hi"
cat /etc/crontab
* * * * * root /etc/echo.sh > /var/log/cron.log 2>&1
/etc/init.d/cron reload
* Reloading configuration files for periodic command scheduler cron [ OK ]
tail -f /var/log/cron.log
hi
After printing "hi" once, nothing happens anymore.
Any ideas why?
cron docker ubuntu-16.04 crontab
add a comment |
I'm trying to run a script every minute (on a Docker container running Ubuntu 16.04)
The /etc/echo.sh
simply echo the word "hi"
cat /etc/crontab
* * * * * root /etc/echo.sh > /var/log/cron.log 2>&1
/etc/init.d/cron reload
* Reloading configuration files for periodic command scheduler cron [ OK ]
tail -f /var/log/cron.log
hi
After printing "hi" once, nothing happens anymore.
Any ideas why?
cron docker ubuntu-16.04 crontab
I'm trying to run a script every minute (on a Docker container running Ubuntu 16.04)
The /etc/echo.sh
simply echo the word "hi"
cat /etc/crontab
* * * * * root /etc/echo.sh > /var/log/cron.log 2>&1
/etc/init.d/cron reload
* Reloading configuration files for periodic command scheduler cron [ OK ]
tail -f /var/log/cron.log
hi
After printing "hi" once, nothing happens anymore.
Any ideas why?
cron docker ubuntu-16.04 crontab
cron docker ubuntu-16.04 crontab
asked 7 hours ago
SigSig
20628
20628
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The script does run every minute but >
truncates the file each time.
If the file does not exist, it shall be created; otherwise, it shall be truncated to be an empty file after being opened.
(source)
Use >>
instead to append to the file.
Won'ttail
saytail: cron.log: file truncated
if the file is truncated? Or am I misunderstanding how tail works
– Ferrybig
3 hours ago
@Ferrybig Iftail
notices the short moment between truncating and placinghi
back, then it will. In my Kubuntuecho hi > cron.log
triggers the message fromtail
in about half the cases. It's a race condition so your (and the OP's) mileage may vary.
– Kamil Maciorowski
3 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f1403597%2fcron-runs-only-once-instead-every-minute%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The script does run every minute but >
truncates the file each time.
If the file does not exist, it shall be created; otherwise, it shall be truncated to be an empty file after being opened.
(source)
Use >>
instead to append to the file.
Won'ttail
saytail: cron.log: file truncated
if the file is truncated? Or am I misunderstanding how tail works
– Ferrybig
3 hours ago
@Ferrybig Iftail
notices the short moment between truncating and placinghi
back, then it will. In my Kubuntuecho hi > cron.log
triggers the message fromtail
in about half the cases. It's a race condition so your (and the OP's) mileage may vary.
– Kamil Maciorowski
3 hours ago
add a comment |
The script does run every minute but >
truncates the file each time.
If the file does not exist, it shall be created; otherwise, it shall be truncated to be an empty file after being opened.
(source)
Use >>
instead to append to the file.
Won'ttail
saytail: cron.log: file truncated
if the file is truncated? Or am I misunderstanding how tail works
– Ferrybig
3 hours ago
@Ferrybig Iftail
notices the short moment between truncating and placinghi
back, then it will. In my Kubuntuecho hi > cron.log
triggers the message fromtail
in about half the cases. It's a race condition so your (and the OP's) mileage may vary.
– Kamil Maciorowski
3 hours ago
add a comment |
The script does run every minute but >
truncates the file each time.
If the file does not exist, it shall be created; otherwise, it shall be truncated to be an empty file after being opened.
(source)
Use >>
instead to append to the file.
The script does run every minute but >
truncates the file each time.
If the file does not exist, it shall be created; otherwise, it shall be truncated to be an empty file after being opened.
(source)
Use >>
instead to append to the file.
edited 4 hours ago
answered 6 hours ago
Kamil MaciorowskiKamil Maciorowski
26.6k155681
26.6k155681
Won'ttail
saytail: cron.log: file truncated
if the file is truncated? Or am I misunderstanding how tail works
– Ferrybig
3 hours ago
@Ferrybig Iftail
notices the short moment between truncating and placinghi
back, then it will. In my Kubuntuecho hi > cron.log
triggers the message fromtail
in about half the cases. It's a race condition so your (and the OP's) mileage may vary.
– Kamil Maciorowski
3 hours ago
add a comment |
Won'ttail
saytail: cron.log: file truncated
if the file is truncated? Or am I misunderstanding how tail works
– Ferrybig
3 hours ago
@Ferrybig Iftail
notices the short moment between truncating and placinghi
back, then it will. In my Kubuntuecho hi > cron.log
triggers the message fromtail
in about half the cases. It's a race condition so your (and the OP's) mileage may vary.
– Kamil Maciorowski
3 hours ago
Won't
tail
say tail: cron.log: file truncated
if the file is truncated? Or am I misunderstanding how tail works– Ferrybig
3 hours ago
Won't
tail
say tail: cron.log: file truncated
if the file is truncated? Or am I misunderstanding how tail works– Ferrybig
3 hours ago
@Ferrybig If
tail
notices the short moment between truncating and placing hi
back, then it will. In my Kubuntu echo hi > cron.log
triggers the message from tail
in about half the cases. It's a race condition so your (and the OP's) mileage may vary.– Kamil Maciorowski
3 hours ago
@Ferrybig If
tail
notices the short moment between truncating and placing hi
back, then it will. In my Kubuntu echo hi > cron.log
triggers the message from tail
in about half the cases. It's a race condition so your (and the OP's) mileage may vary.– Kamil Maciorowski
3 hours ago
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f1403597%2fcron-runs-only-once-instead-every-minute%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