• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Cron command execution is broken partially

Scheduled Pinned Locked Moved 2.4 Development Snapshots
4 Posts 2 Posters 830 Views
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.
  • W
    w0w
    last edited by Dec 22, 2017, 6:35 PM Dec 21, 2017, 4:50 PM

    Looks like the input field for the command is not limited to appropriate length and command got truncated when exceeds some limit used by cron. It would be very useful to limit input length according to maximum allowed by cron or at least developers can add note about limited length.
    Does anybody knows what maximum command length is acceptable by cron?

    1 Reply Last reply Reply Quote 0
    • J
      jimp Rebel Alliance Developer Netgate
      last edited by Dec 22, 2017, 2:25 PM

      I'm not aware of a limit specifically in cron, but in general the command line limit varies from shell to shell. The man page for crontab(5) doesn't mention a limit.

      Past a certain point though you should be using a script and not a gigantic command line.

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      1 Reply Last reply Reply Quote 0
      • W
        w0w
        last edited by Dec 23, 2017, 4:56 AM Dec 22, 2017, 6:28 PM

        Sorry for bothering you, jimp. I did not find this limit anywhere documented also and I using script now, but I just wanted to hold all my settings in config file, my command length was ~ 243 chars and I started playing with echo command posting some output via cron to a file. I have just found that it's not length but just lack of necessary knowledge on my side and some cron bug/features, because it runs only half (first 4) of multiple sequental commands via cron and same sequence runs just fine till the end via shell.

        
        zfs snapshot -r zroot@currentsnap && zfs send -R zroot@currentsnap | gzip > /root/backup/currentsnap.gz && zfs destroy -r zroot@currentsnap && curl --upload-file /root/backup/currentsnap.gz ftp://pf@10.0.88.3:2121 && rm /root/backup/currentsnap.gz
        
        

        No matter what I have tried it run untill "&& curl…" and then just stops. If I run similar #!/bin/sh script or directly in shell it works. I think there is something else in cron that just don't like this command sequence.

        1 Reply Last reply Reply Quote 0
        • W
          w0w
          last edited by Dec 23, 2017, 5:31 AM

          Tried to add path

          /sbin/zfs snapshot -r zroot@currentsnap && /sbin/zfs send -R zroot@currentsnap | /usr/bin/gzip > /root/backup/currentsnap.gz && /sbin/zfs destroy -r zroot@currentsnap && /usr/local/bin/curl --upload-file /root/backup/currentsnap.gz ftp://pf@10.0.88.3:2121 && /bin/rm /root/backup/currentsnap.gz
          

          Not helped.

          At the end I got it working via bash package

          /usr/local/bin/bash -c 'zfs snapshot -r zroot@currentsnap && zfs send -R zroot@currentsnap | gzip > /root/backup/currentsnap.gz && zfs destroy -r zroot@currentsnap && curl --upload-file /root/backup/currentsnap.gz ftp://pf@10.0.88.3:2121 && rm /root/backup/currentsnap.gz'
          
          1 Reply Last reply Reply Quote 0
          4 out of 4
          • First post
            4/4
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
            This community forum collects and processes your personal information.
            consent.not_received