Q: cron - one script works while the other doesn't I am on Archlinux and I am trying to force a cron application to execute my script. So I installed package fcron and ran it's daemon first and then I added fcrontab which looks like this: 
* * * * * /home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescript

Ok so this is where it gets tricky. This script will execute if it's contents looks like this: 
#!/bin/bash
PATH=/usr/bin
touch ~/test-002.txt

But it won't execute if it's contents look like this: 
#!/bin/bash
PATH=/usr/bin
acpi -b | awk -F'[,:%]' '{print $2, $3}' | {
    read -r status capacity
    if [ "$status" = Discharging -a "$capacity" -lt 5 ]; then
        logger "Critical battery threshold"
        systemctl hibernate
    fi
}

Why is that? Even the Archlinux Wiki says it should work, but I assume it is wrong - I only changed #!/bin/bash and added PATH=/usr/bin. Script works on its own...

EDIT:
So I edited my script to look like below and it doesn't work. 
#!/bin/sh
SHELL=/bin/sh

/usr/bin/acpi -b | /usr/bin/awk -F'[,:%]' '{print $2, $3}' | (
    read -r status capacity
    if [ "$status" = Discharging ] && [ "$capacity" -lt 50 ]; then
        /usr/bin/systemctl hibernate
    fi
)

If I run
[ziga@ziga-laptop hibernate]$ run-parts ~/Dropbox/workspace/operacijski/archlinux/hibernate/ -v
run-parts: executing /home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate//hibernatescript

My PC hibernates, but again cron doesn't hibernate my PC using the exact same script. I also tried fcron and it doesn't work although daemon is fully running and fcrontab is set. Again this works for any simpler scripts while it wont work for this one. 
Here are some info:
[ziga@ziga-laptop ~]$ systemctl status fcron.service     
● fcron.service - fcron periodical command scheduler
   Loaded: loaded (/usr/lib/systemd/system/fcron.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2016-06-21 10:39:48 CEST; 58min ago
  Process: 419 ExecStart=/usr/bin/fcron (code=exited, status=0/SUCCESS)
 Main PID: 423 (fcron)
    Tasks: 1 (limit: 512)
   CGroup: /system.slice/fcron.service
           └─423 /usr/bin/fcron

Jun 21 11:34:00 ziga-laptop fcron[12833]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:34:02 ziga-laptop fcron[12833]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:35:00 ziga-laptop fcron[13021]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:35:02 ziga-laptop fcron[13021]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:36:00 ziga-laptop fcron[13210]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:36:02 ziga-laptop fcron[13210]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:37:00 ziga-laptop fcron[13407]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:37:02 ziga-laptop fcron[13407]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:38:00 ziga-laptop fcron[13599]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
Jun 21 11:38:02 ziga-laptop fcron[13599]: Job '/home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescrip
[ziga@ziga-laptop ~]$ fcrontab -l
2016-06-21 11:38:48  INFO listing ziga's fcrontab
* * * * * /home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescript
[ziga@ziga-laptop ~]$ cat /home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/hibernatescript
#!/bin/sh
SHELL=/bin/sh

/usr/bin/acpi -b | /usr/bin/awk -F'[,:%]' '{print $2, $3}' | (
        read -r status capacity
        if [ "$status" = Discharging ] && [ "$capacity" -lt 50 ]; then
                /usr/bin/systemctl hibernate
        fi
)
[ziga@ziga-laptop ~]$ ls -l /home/ziga/Dropbox/workspace/operacijski/archlinux/hibernate/
total 16
-rwxrwxrwx 1 ziga users  214 Jun 21 08:46 hibernatescript
-rw-rw-rw- 1 ziga users 2832 Jun 21 00:24 README.txt
[ziga@ziga-laptop ~]$ groups ziga
lp audio bumblebee users
[ziga@ziga-laptop ~]$ 

