ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Need some help with crontab

    IT Discussion
    crontab centos snipe-it
    4
    15
    1.6k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403
      last edited by

      I'm accessing the crontab file using my user, with sudo access. Below is the entire crontab file.

      SHELL=/bin/bash
      PATH=/sbin:/bin:/usr/sbin:/usr/bin
      MAILTO=root
      
      # For details see man 4 crontabs
      
      # Example of job definition:
      # .---------------- minute (0 - 59)
      # |  .------------- hour (0 - 23)
      # |  |  .---------- day of month (1 - 31)
      # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
      # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
      # |  |  |  |  |
      # *  *  *  *  * user-name  command to be executed
        *  15 *  *  1 /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts
      ~
      ~
      ~
      ~
      ~
      ~
      "/etc/crontab" 15L, 533C
      
      black3dynamiteB 1 Reply Last reply Reply Quote 0
      • black3dynamiteB
        black3dynamite @DustinB3403
        last edited by black3dynamite

        @dustinb3403
        Maybe its something to do with the mailto variable.

        DustinB3403D 1 Reply Last reply Reply Quote 0
        • DustinB3403D
          DustinB3403
          last edited by

          I just changed the job to include my username. We'll see how that goes.

          1 Reply Last reply Reply Quote 0
          • DustinB3403D
            DustinB3403 @black3dynamite
            last edited by

            @black3dynamite said in Need some help with crontab:

            @dustinb3403
            Maybe its something to do with the mailto variable.

            I don't think that is the issue, as I didn't add that. The only part I added was the command.

            I configured this to run at 11AM EST (16:00 UTC) and will report back a few minutes.

            momurdaM 1 Reply Last reply Reply Quote 0
            • momurdaM
              momurda @DustinB3403
              last edited by

              @dustinb3403 /usr/bin/php isnt a user. I think you need to quote up.

              DustinB3403D 1 Reply Last reply Reply Quote 0
              • DustinB3403D
                DustinB3403 @momurda
                last edited by

                @momurda said in Need some help with crontab:

                @dustinb3403 /usr/bin/php isnt a user. I think you need to quote up.

                So ?

                  @weekly "/usr/bin/php" "/var/www/html/snipeit/artisan snipeit:expiring-alerts"
                
                1 Reply Last reply Reply Quote 0
                • DustinB3403D
                  DustinB3403
                  last edited by DustinB3403

                  @dustinb3403 said in Need some help with crontab:

                  "/usr/bin/php" "/var/www/html/snipeit/artisan snipeit:expiring-alerts"

                  trying this

                  10 16 * * 1 "/usr/bin/php" "/var/www/html/snipeit/artisan" "snipeit:expiring-alerts"
                  
                  1 Reply Last reply Reply Quote 0
                  • DustinB3403D
                    DustinB3403
                    last edited by

                    That didn't work. . .

                    black3dynamiteB 1 Reply Last reply Reply Quote 0
                    • black3dynamiteB
                      black3dynamite @DustinB3403
                      last edited by

                      @dustinb3403 said in Need some help with crontab:

                      That didn't work. . .

                      Have you tried that command under root crontab?

                      DustinB3403D 1 Reply Last reply Reply Quote 0
                      • DustinB3403D
                        DustinB3403 @black3dynamite
                        last edited by DustinB3403

                        @black3dynamite said in Need some help with crontab:

                        @dustinb3403 said in Need some help with crontab:

                        That didn't work. . .

                        Have you tried that command under root crontab?

                        Stepping into su and running the command words.

                          su root
                          > pass
                          /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts
                        

                        So this has to be with the way I have it configured. I wonder if I need to create a bash script, and simply have cron call that rather than using the lines like above in cron. . .

                        If I do then the documentation is misleading. . .

                        1 Reply Last reply Reply Quote 1
                        • DustinB3403D
                          DustinB3403
                          last edited by DustinB3403

                          I've created a simple script and have cron set to run the script at 11:35AM. So I'll see if that works.

                          Executing the script from SSH works without issue. . .

                          So we'll see. . .

                          1 Reply Last reply Reply Quote 0
                          • DustinB3403D
                            DustinB3403
                            last edited by DustinB3403

                            Ok and that is what it was.

                            Simply needed to make a bash script out of it and have it scheduled to run, rather than using the commands directly in cron.

                            Problem solved.

                            Solution:

                            pwd
                            /usr/bin/local
                            touch expiring-alert.sh
                            vi expiring-alert.sh
                                 /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts
                             sudo vi /etc/crontab
                                 35 * * * 1 <user> /usr/local/bin/expiring-alert.sh
                            

                            Presumably changing this to be @daily or @weekly would work as well.

                            dbeatoD 1 Reply Last reply Reply Quote 3
                            • dbeatoD
                              dbeato @DustinB3403
                              last edited by

                              @dustinb3403 said in Need some help with crontab:

                              Ok and that is what it was.

                              Simply needed to make a bash script out of it and have it scheduled to run, rather than using the commands directly in cron.

                              Problem solved.

                              Solution:

                              pwd
                              /usr/bin/local
                              touch expiring-alert.sh
                              vi expiring-alert.sh
                                   /usr/bin/php /var/www/html/snipeit/artisan snipeit:expiring-alerts
                               sudo vi /etc/crontab
                                   35 * * * 1 <user> /usr/local/bin/expiring-alert.sh
                              

                              Presumably changing this to be @daily or @weekly would work as well.

                              MOst of the time that is how I have it setup on my crontab, same for my certbot scripts too.

                              1 Reply Last reply Reply Quote 0
                              • 1 / 1
                              • First post
                                Last post