How to set up an hourly Cron job to run `grive` from `/etc/cron.hourly`?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
I added the file grive.sh
to /etc/cron.daily
but the command doesn't seem to be running. I also copied it to /etc/cron.hourly
but there has been no change to my Google Drive directory only. The file has only three lines:
#! /bin/sh
cd /media/james/Seagate Expansion Drive/GD
grive
The permissions are read-only so I'll update those.
I used /etc/cron.hourly# chmod u+rwx grive.sh
, but then when I check the permissions for the file in Nautilus, they are unchangedâÂÂI don't know why.
I can run grive
manually from the terminal, and the files sync locally and online.
root@james-Streacom:/etc/cron.hourly# grep CRON /var/log/syslog
Feb 1 09:17:02 james-Streacom CRON[8696]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 10:17:01 james-Streacom CRON[10958]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 11:17:01 james-Streacom CRON[12897]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 12:17:01 james-Streacom CRON[15307]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 13:17:01 james-Streacom CRON[17043]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 14:17:01 james-Streacom CRON[17354]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 15:17:01 james-Streacom CRON[17705]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
root@james-Streacom:/etc/cron.hourly# cd / && run-parts --report /etc/cron.hourly
root@james-Streacom:/# bash -c "cd / && run-parts --report /etc/cron.hourly"
root@james-Streacom:/#
Note that this may be a duplicate of The cron job doesn't work when put in `/etc/cron.hourly/` but work when defined in `crontab -e`, I'm just going through those steps.
I added echo test >/tmp/foobar.tmp
to the last line of the script.
root@james-Streacom:/etc/cron.hourly# grep 'cron.hourly' /etc/crontab
17 * * * * root cd / && run-parts --report /etc/cron.hourly
/temp/foobar.tmp
doesn't exist.
I tried to actually run # cd /media/james/Seagate Expansion Drive/GD
, and got the error -su: cd: too many arguments
. I then changed the cd line in the script to cd /media/james/"Seagate Expansion Drive"/GD
.
$ echo test >/tmp/foobar.tmp
does create the file with test in it.# echo test2 >/tmp/foobar.tmp
overwrites test with test2.
cron grive
add a comment |Â
up vote
0
down vote
favorite
I added the file grive.sh
to /etc/cron.daily
but the command doesn't seem to be running. I also copied it to /etc/cron.hourly
but there has been no change to my Google Drive directory only. The file has only three lines:
#! /bin/sh
cd /media/james/Seagate Expansion Drive/GD
grive
The permissions are read-only so I'll update those.
I used /etc/cron.hourly# chmod u+rwx grive.sh
, but then when I check the permissions for the file in Nautilus, they are unchangedâÂÂI don't know why.
I can run grive
manually from the terminal, and the files sync locally and online.
root@james-Streacom:/etc/cron.hourly# grep CRON /var/log/syslog
Feb 1 09:17:02 james-Streacom CRON[8696]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 10:17:01 james-Streacom CRON[10958]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 11:17:01 james-Streacom CRON[12897]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 12:17:01 james-Streacom CRON[15307]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 13:17:01 james-Streacom CRON[17043]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 14:17:01 james-Streacom CRON[17354]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 15:17:01 james-Streacom CRON[17705]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
root@james-Streacom:/etc/cron.hourly# cd / && run-parts --report /etc/cron.hourly
root@james-Streacom:/# bash -c "cd / && run-parts --report /etc/cron.hourly"
root@james-Streacom:/#
Note that this may be a duplicate of The cron job doesn't work when put in `/etc/cron.hourly/` but work when defined in `crontab -e`, I'm just going through those steps.
I added echo test >/tmp/foobar.tmp
to the last line of the script.
root@james-Streacom:/etc/cron.hourly# grep 'cron.hourly' /etc/crontab
17 * * * * root cd / && run-parts --report /etc/cron.hourly
/temp/foobar.tmp
doesn't exist.
I tried to actually run # cd /media/james/Seagate Expansion Drive/GD
, and got the error -su: cd: too many arguments
. I then changed the cd line in the script to cd /media/james/"Seagate Expansion Drive"/GD
.
$ echo test >/tmp/foobar.tmp
does create the file with test in it.# echo test2 >/tmp/foobar.tmp
overwrites test with test2.
cron grive
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I added the file grive.sh
to /etc/cron.daily
but the command doesn't seem to be running. I also copied it to /etc/cron.hourly
but there has been no change to my Google Drive directory only. The file has only three lines:
#! /bin/sh
cd /media/james/Seagate Expansion Drive/GD
grive
The permissions are read-only so I'll update those.
I used /etc/cron.hourly# chmod u+rwx grive.sh
, but then when I check the permissions for the file in Nautilus, they are unchangedâÂÂI don't know why.
I can run grive
manually from the terminal, and the files sync locally and online.
root@james-Streacom:/etc/cron.hourly# grep CRON /var/log/syslog
Feb 1 09:17:02 james-Streacom CRON[8696]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 10:17:01 james-Streacom CRON[10958]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 11:17:01 james-Streacom CRON[12897]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 12:17:01 james-Streacom CRON[15307]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 13:17:01 james-Streacom CRON[17043]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 14:17:01 james-Streacom CRON[17354]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 15:17:01 james-Streacom CRON[17705]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
root@james-Streacom:/etc/cron.hourly# cd / && run-parts --report /etc/cron.hourly
root@james-Streacom:/# bash -c "cd / && run-parts --report /etc/cron.hourly"
root@james-Streacom:/#
Note that this may be a duplicate of The cron job doesn't work when put in `/etc/cron.hourly/` but work when defined in `crontab -e`, I'm just going through those steps.
I added echo test >/tmp/foobar.tmp
to the last line of the script.
root@james-Streacom:/etc/cron.hourly# grep 'cron.hourly' /etc/crontab
17 * * * * root cd / && run-parts --report /etc/cron.hourly
/temp/foobar.tmp
doesn't exist.
I tried to actually run # cd /media/james/Seagate Expansion Drive/GD
, and got the error -su: cd: too many arguments
. I then changed the cd line in the script to cd /media/james/"Seagate Expansion Drive"/GD
.
$ echo test >/tmp/foobar.tmp
does create the file with test in it.# echo test2 >/tmp/foobar.tmp
overwrites test with test2.
cron grive
I added the file grive.sh
to /etc/cron.daily
but the command doesn't seem to be running. I also copied it to /etc/cron.hourly
but there has been no change to my Google Drive directory only. The file has only three lines:
#! /bin/sh
cd /media/james/Seagate Expansion Drive/GD
grive
The permissions are read-only so I'll update those.
I used /etc/cron.hourly# chmod u+rwx grive.sh
, but then when I check the permissions for the file in Nautilus, they are unchangedâÂÂI don't know why.
I can run grive
manually from the terminal, and the files sync locally and online.
root@james-Streacom:/etc/cron.hourly# grep CRON /var/log/syslog
Feb 1 09:17:02 james-Streacom CRON[8696]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 10:17:01 james-Streacom CRON[10958]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 11:17:01 james-Streacom CRON[12897]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 12:17:01 james-Streacom CRON[15307]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 13:17:01 james-Streacom CRON[17043]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 14:17:01 james-Streacom CRON[17354]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Feb 1 15:17:01 james-Streacom CRON[17705]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
root@james-Streacom:/etc/cron.hourly# cd / && run-parts --report /etc/cron.hourly
root@james-Streacom:/# bash -c "cd / && run-parts --report /etc/cron.hourly"
root@james-Streacom:/#
Note that this may be a duplicate of The cron job doesn't work when put in `/etc/cron.hourly/` but work when defined in `crontab -e`, I'm just going through those steps.
I added echo test >/tmp/foobar.tmp
to the last line of the script.
root@james-Streacom:/etc/cron.hourly# grep 'cron.hourly' /etc/crontab
17 * * * * root cd / && run-parts --report /etc/cron.hourly
/temp/foobar.tmp
doesn't exist.
I tried to actually run # cd /media/james/Seagate Expansion Drive/GD
, and got the error -su: cd: too many arguments
. I then changed the cd line in the script to cd /media/james/"Seagate Expansion Drive"/GD
.
$ echo test >/tmp/foobar.tmp
does create the file with test in it.# echo test2 >/tmp/foobar.tmp
overwrites test with test2.
cron grive
cron grive
edited Feb 1 at 5:34
asked Feb 1 at 4:11
James Ray
218114
218114
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
Aside from the unquoted whitespace in your original script (which you seem to have corrected) the issue is likely with the naming of your script.
According to the DEBIAN SPECIFIC
section of man cron
:
As described above, the files under these directories have to be pass
some sanity checks including the following: be executable, be owned by
root, not be writable by group or other and, if symlinks, point to
files owned by root. Additionally, the file names must conform to the
filename requirements of run-parts: they must be entirely made up of
letters, digits and can only contain the special signs underscores
('_') and hyphens ('-'). Any file that does not conform to these
requirements will not be executed by run-parts. For example, any file
containing dots will be ignored. This is done to prevent cron from
running any of the files that are left by the Debian package management
system when handling files in /etc/cron.d/ as configuration files (i.e.
files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
Since grive.sh
has a dot in its name, run-parts
will ignore it.
Thanks, I renamed the file togrive
, and will wait an hour and see whether it runs.
â James Ray
Feb 2 at 7:40
add a comment |Â
up vote
0
down vote
I don't really get your question, although in my experience some commands doesn't work as expected when you add them into a script and put in a cronjob.
I'd start by adding it to new file in /etc/cron.d/test
as following (I'll configure it every 5 minutes just to get some logs for testing purposes):
# m h dom mon dow user command
*/5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
Please see stdout in /var/log/grivesh.log
, once you have it analized you can have cronjob configured once every hour like this (e.g. at minute 5 every hour):
# m h dom mon dow user command
5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
It is necesary to have it in /etc/cron.hourly/
? Don't you preefer to have it in /etc/cron.d/
or in a crontab for your user?
Regards,
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Aside from the unquoted whitespace in your original script (which you seem to have corrected) the issue is likely with the naming of your script.
According to the DEBIAN SPECIFIC
section of man cron
:
As described above, the files under these directories have to be pass
some sanity checks including the following: be executable, be owned by
root, not be writable by group or other and, if symlinks, point to
files owned by root. Additionally, the file names must conform to the
filename requirements of run-parts: they must be entirely made up of
letters, digits and can only contain the special signs underscores
('_') and hyphens ('-'). Any file that does not conform to these
requirements will not be executed by run-parts. For example, any file
containing dots will be ignored. This is done to prevent cron from
running any of the files that are left by the Debian package management
system when handling files in /etc/cron.d/ as configuration files (i.e.
files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
Since grive.sh
has a dot in its name, run-parts
will ignore it.
Thanks, I renamed the file togrive
, and will wait an hour and see whether it runs.
â James Ray
Feb 2 at 7:40
add a comment |Â
up vote
2
down vote
Aside from the unquoted whitespace in your original script (which you seem to have corrected) the issue is likely with the naming of your script.
According to the DEBIAN SPECIFIC
section of man cron
:
As described above, the files under these directories have to be pass
some sanity checks including the following: be executable, be owned by
root, not be writable by group or other and, if symlinks, point to
files owned by root. Additionally, the file names must conform to the
filename requirements of run-parts: they must be entirely made up of
letters, digits and can only contain the special signs underscores
('_') and hyphens ('-'). Any file that does not conform to these
requirements will not be executed by run-parts. For example, any file
containing dots will be ignored. This is done to prevent cron from
running any of the files that are left by the Debian package management
system when handling files in /etc/cron.d/ as configuration files (i.e.
files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
Since grive.sh
has a dot in its name, run-parts
will ignore it.
Thanks, I renamed the file togrive
, and will wait an hour and see whether it runs.
â James Ray
Feb 2 at 7:40
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Aside from the unquoted whitespace in your original script (which you seem to have corrected) the issue is likely with the naming of your script.
According to the DEBIAN SPECIFIC
section of man cron
:
As described above, the files under these directories have to be pass
some sanity checks including the following: be executable, be owned by
root, not be writable by group or other and, if symlinks, point to
files owned by root. Additionally, the file names must conform to the
filename requirements of run-parts: they must be entirely made up of
letters, digits and can only contain the special signs underscores
('_') and hyphens ('-'). Any file that does not conform to these
requirements will not be executed by run-parts. For example, any file
containing dots will be ignored. This is done to prevent cron from
running any of the files that are left by the Debian package management
system when handling files in /etc/cron.d/ as configuration files (i.e.
files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
Since grive.sh
has a dot in its name, run-parts
will ignore it.
Aside from the unquoted whitespace in your original script (which you seem to have corrected) the issue is likely with the naming of your script.
According to the DEBIAN SPECIFIC
section of man cron
:
As described above, the files under these directories have to be pass
some sanity checks including the following: be executable, be owned by
root, not be writable by group or other and, if symlinks, point to
files owned by root. Additionally, the file names must conform to the
filename requirements of run-parts: they must be entirely made up of
letters, digits and can only contain the special signs underscores
('_') and hyphens ('-'). Any file that does not conform to these
requirements will not be executed by run-parts. For example, any file
containing dots will be ignored. This is done to prevent cron from
running any of the files that are left by the Debian package management
system when handling files in /etc/cron.d/ as configuration files (i.e.
files ending in .dpkg-dist, .dpkg-orig, and .dpkg-new).
Since grive.sh
has a dot in its name, run-parts
will ignore it.
answered Feb 1 at 11:28
steeldriver
63.6k1199167
63.6k1199167
Thanks, I renamed the file togrive
, and will wait an hour and see whether it runs.
â James Ray
Feb 2 at 7:40
add a comment |Â
Thanks, I renamed the file togrive
, and will wait an hour and see whether it runs.
â James Ray
Feb 2 at 7:40
Thanks, I renamed the file to
grive
, and will wait an hour and see whether it runs.â James Ray
Feb 2 at 7:40
Thanks, I renamed the file to
grive
, and will wait an hour and see whether it runs.â James Ray
Feb 2 at 7:40
add a comment |Â
up vote
0
down vote
I don't really get your question, although in my experience some commands doesn't work as expected when you add them into a script and put in a cronjob.
I'd start by adding it to new file in /etc/cron.d/test
as following (I'll configure it every 5 minutes just to get some logs for testing purposes):
# m h dom mon dow user command
*/5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
Please see stdout in /var/log/grivesh.log
, once you have it analized you can have cronjob configured once every hour like this (e.g. at minute 5 every hour):
# m h dom mon dow user command
5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
It is necesary to have it in /etc/cron.hourly/
? Don't you preefer to have it in /etc/cron.d/
or in a crontab for your user?
Regards,
add a comment |Â
up vote
0
down vote
I don't really get your question, although in my experience some commands doesn't work as expected when you add them into a script and put in a cronjob.
I'd start by adding it to new file in /etc/cron.d/test
as following (I'll configure it every 5 minutes just to get some logs for testing purposes):
# m h dom mon dow user command
*/5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
Please see stdout in /var/log/grivesh.log
, once you have it analized you can have cronjob configured once every hour like this (e.g. at minute 5 every hour):
# m h dom mon dow user command
5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
It is necesary to have it in /etc/cron.hourly/
? Don't you preefer to have it in /etc/cron.d/
or in a crontab for your user?
Regards,
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I don't really get your question, although in my experience some commands doesn't work as expected when you add them into a script and put in a cronjob.
I'd start by adding it to new file in /etc/cron.d/test
as following (I'll configure it every 5 minutes just to get some logs for testing purposes):
# m h dom mon dow user command
*/5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
Please see stdout in /var/log/grivesh.log
, once you have it analized you can have cronjob configured once every hour like this (e.g. at minute 5 every hour):
# m h dom mon dow user command
5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
It is necesary to have it in /etc/cron.hourly/
? Don't you preefer to have it in /etc/cron.d/
or in a crontab for your user?
Regards,
I don't really get your question, although in my experience some commands doesn't work as expected when you add them into a script and put in a cronjob.
I'd start by adding it to new file in /etc/cron.d/test
as following (I'll configure it every 5 minutes just to get some logs for testing purposes):
# m h dom mon dow user command
*/5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
Please see stdout in /var/log/grivesh.log
, once you have it analized you can have cronjob configured once every hour like this (e.g. at minute 5 every hour):
# m h dom mon dow user command
5 * * * * root [DIR_TO_SCRIPT]/grive.sh >> /var/log/grivesh.log 2>&1
It is necesary to have it in /etc/cron.hourly/
? Don't you preefer to have it in /etc/cron.d/
or in a crontab for your user?
Regards,
answered Feb 1 at 10:19
Alvaro Niño
2337
2337
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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%2faskubuntu.com%2fquestions%2f1001933%2fhow-to-set-up-an-hourly-cron-job-to-run-grive-from-etc-cron-hourly%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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