Cron command execution is broken partially



  • 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?


  • Rebel Alliance Developer Netgate

    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.



  • 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.



  • 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'