How to set up an hourly Cron job to run `grive` from `/etc/cron.hourly`?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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.










share|improve this question



























    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.










    share|improve this question

























      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.










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 1 at 5:34

























      asked Feb 1 at 4:11









      James Ray

      218114




      218114




















          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.






          share|improve this answer




















          • Thanks, I renamed the file to grive, and will wait an hour and see whether it runs.
            – James Ray
            Feb 2 at 7:40

















          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,






          share|improve this answer




















            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',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            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






























            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.






            share|improve this answer




















            • Thanks, I renamed the file to grive, and will wait an hour and see whether it runs.
              – James Ray
              Feb 2 at 7:40














            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.






            share|improve this answer




















            • Thanks, I renamed the file to grive, and will wait an hour and see whether it runs.
              – James Ray
              Feb 2 at 7:40












            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.






            share|improve this answer












            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 1 at 11:28









            steeldriver

            63.6k1199167




            63.6k1199167











            • 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















            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












            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,






            share|improve this answer
























              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,






              share|improve this answer






















                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,






                share|improve this answer












                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,







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 1 at 10:19









                Alvaro Niño

                2337




                2337



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    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













































































                    Popular posts from this blog

                    pylint3 and pip3 broken

                    Missing snmpget and snmpwalk

                    How to enroll fingerprints to Ubuntu 17.10 with VFS491