I am having issues with this script/cron. I am running on a Raspberry pi and I have other cronjobs working just fine(so I know its not cron on the system).
My script:
#!/bin/bash
rm -f /var/www/output/*
This script is working just fine in the command line
bash clearcsv.sh
but when I try to turn it in to a cronjob, it seems that it is not executing
Cron script: */6 * * * * /home/pi/clearcsv.sh
This should erase the contents of the "output" folder every 6 minutes, but it does not. If someone could tell me where I am failing or point me in the right direction that would be great
Thanks
total 160
drwxrwxrwx 14 pi pi 4096 Mar 13 16:41 .
drwxr-xr-x 3 root root 4096 Dec 31 1969 ..
-rw-r--r-- 1 pi pi 0 Mar 10 21:56 ?
-rwxrwxrwx 1 pi pi 8700 Mar 13 15:32 .bash_history
-rwxrwxrwx 1 pi pi 220 Jan 7 16:10 .bash_logout
-rwxrwxrwx 1 pi pi 3243 Jan 7 16:10 .bashrc
drwxrwxrwx 8 pi pi 4096 Mar 10 19:24 .cache
-rwxrwxrwx 1 pi pi 41 Mar 13 16:11 clearcsv.sh
drwxrwxrwx 12 pi pi 4096 Feb 12 18:21 .config
-rwxrwxrwx 1 pi pi 420 Mar 13 17:02 csv.sh
drwxrwxrwx 2 pi pi 4096 Feb 12 18:20 Desktop
-rw-r--r-- 1 pi pi 35 Mar 7 08:17 .dmrc
drwxrwxrwx 2 pi pi 4096 Jan 16 13:32 .fontconfig
drwxrwxrwx 2 pi indiecity 4096 Jan 16 13:34 .gstreamer-0.10
drwxrwxrwx 2 pi pi 4096 Jan 16 13:32 .gvfs
drwxrwxrwx 3 pi pi 4096 Jan 16 13:33 indiecity
drwxrwxrwx 2 pi pi 4096 Mar 13 13:27 input
drwxrwxrwx 3 pi pi 4096 Jan 16 13:33 .local
drwxrwxrwx 9 pi pi 4096 Jan 16 14:30 .Mathematica
-rwxrwxrwx 1 pi pi 5781 Feb 3 2013 ocr_pi.png
-rwxrwxrwx 1 pi pi 0 Mar 10 18:24 output.csv
-rwxrwxrwx 1 pi pi 671 Mar 13 13:39 poller.sh
-rwxrwxrwx 1 pi pi 117 Feb 19 17:34 poll.sh
-rwxrwxrwx 1 pi pi 675 Jan 7 16:10 .profile
-rw-r--r-- 1 root root 3 Jan 16 14:09 restart
drwx------ 4 pi pi 4096 Mar 13 13:22 .thumbnails
-rwxrwxrwx 1 pi pi 56 Mar 7 08:17 .Xauthority
-rw------- 1 pi pi 17227 Mar 13 16:56 .xsession-errors
-rwxrwxrwx 1 pi pi 2385 Mar 6 19:06 .xsession-errors.old
Thank you all for your help. I have everything working now! Here is the code if you are interested
New Script used:
#!/bin/bash
/bin/rm -f /var/www/output/*
Cron
*/6 * * * * cd /home/pi && bash clearcsv.sh
Related
I am trying to get "glob-expand-word" to work
pi#raspberrypi:~ $ cat .inputrc
set editing-mode vi
set keymap vi
set show-all-if-ambiguous on
Control-o: "> output"
pi#raspberrypi:~/tmp/test4 $ ls
total 8.0K
drwxr-xr-x 10 pi pi 4.0K Jan 27 08:48 ..
-rw-r--r-- 1 pi pi 0 Jan 27 08:48 3_eng
-rw-r--r-- 1 pi pi 0 Jan 27 08:48 2_eng
-rw-r--r-- 1 pi pi 0 Jan 27 08:48 1_eng
drwxr-xr-x 2 pi pi 4.0K Jan 27 08:48 .
pi#raspberrypi:~/tmp/test4 $ ls *eng^X
When trying to do the ctrlx, * (a two stroke combo) it doesn't work - instead of auto-completing and outputting "ls 1_eng 2_eng 3_eng" it instead appends ^X
What can I try next?
Try to bind ctrl-x :
bind '"\C-x": glob-list-expansions'
# Then -> ls *eng^X
I have a qcow2 image which I have converted to raw format, and then mount to my file system:
# qemu-img convert -O raw initial-image.qcow2 raw-image.img
# kpartx -av raw-image.img
add map loop0p1 (253:1): 0 41940992 linear /dev/loop0 2048
# mount /dev/mapper/loop0p1 ~/myImage
# ls ~/myImage
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
The size of ~/myImage mountpoint is checked with du command as follows:
# du -hx --max-depth=1 ~/myImage/
0 /root/myImage/dev
0 /root/myImage/proc
0 /root/myImage/run
0 /root/myImage/sys
36M /root/myImage/etc
40K /root/myImage/root
53M /root/myImage/var
12K /root/myImage/tmp
834M /root/myImage/usr
89M /root/myImage/boot
0 /root/myImage/home
0 /root/myImage/media
0 /root/myImage/mnt
0 /root/myImage/opt
0 /root/myImage/srv
1012M /root/myImage/
At this point I copied the contents of ~/myImage and pasted them inside ~/myImage-copy directory. Then I checked the size of the newly created directory. I expected the exact same size for each directory between ~/myImage and ~/myImage-copy, but it's not:
# cp -R myImage/ ~/myImage-copy
# du -hx --max-depth=1 ~/myImage-copy/
0 /root/myImage-copy/dev
0 /root/myImage-copy/proc
0 /root/myImage-copy/run
0 /root/myImage-copy/sys
36M /root/myImage-copy/etc
40K /root/myImage-copy/root
63M /root/myImage-copy/var
12K /root/myImage-copy/tmp
862M /root/myImage-copy/usr
89M /root/myImage-copy/boot
0 /root/myImage-copy/home
0 /root/myImage-copy/media
0 /root/myImage-copy/mnt
0 /root/myImage-copy/opt
0 /root/myImage-copy/srv
1.1G /root/myImage-copy/
From the paths above with different size, I chose /usr and I followed a branch of it until I conclude to an innermost directory which has different size, in order to inspect its files. Below is shown the size difference of an innermost directory:
# du -hx --max-depth=1 ~/myImage/usr/lib64/python2.7/json/
112K /root/myImage/usr/lib64/python2.7/json/
# du -hx --max-depth=1 ~/myImage-copy/usr/lib64/python2.7/json/
164K /root/myImage-copy/usr/lib64/python2.7/json/
However, by inspecting their file content, I can't see any difference related to their size. I don't know if the second column plays a role:
# ls -lah ~/myImage/usr/lib64/python2.7/json/
total 200K
drwxr-xr-x. 2 root root 280 Feb 3 11:17 .
drwxr-xr-x. 26 root root 20K Feb 3 11:17 ..
-rw-r--r--. 1 root root 14K Aug 13 2020 decoder.py
-rw-r--r--. 2 root root 12K Aug 13 2020 decoder.pyc
-rw-r--r--. 2 root root 12K Aug 13 2020 decoder.pyo
-rw-r--r--. 1 root root 17K Aug 13 2020 encoder.py
-rw-r--r--. 2 root root 14K Aug 13 2020 encoder.pyc
-rw-r--r--. 2 root root 14K Aug 13 2020 encoder.pyo
-rw-r--r--. 1 root root 15K Aug 13 2020 __init__.py
-rw-r--r--. 2 root root 14K Aug 13 2020 __init__.pyc
-rw-r--r--. 2 root root 14K Aug 13 2020 __init__.pyo
-rw-r--r--. 1 root root 2.3K Aug 13 2020 scanner.py
-rw-r--r--. 2 root root 2.2K Aug 13 2020 scanner.pyc
-rw-r--r--. 2 root root 2.2K Aug 13 2020 scanner.pyo
-rw-r--r--. 1 root root 997 Aug 13 2020 tool.py
-rw-r--r--. 2 root root 1.3K Aug 13 2020 tool.pyc
-rw-r--r--. 2 root root 1.3K Aug 13 2020 tool.pyo
# ls -lah ~/myImage-copy/usr/lib64/python2.7/json/
total 200K
drwxr-xr-x 2 root root 280 Mar 4 17:55 .
drwxr-xr-x 26 root root 20K Mar 4 17:55 ..
-rw-r--r-- 1 root root 14K Mar 4 17:55 decoder.py
-rw-r--r-- 1 root root 12K Mar 4 17:55 decoder.pyc
-rw-r--r-- 1 root root 12K Mar 4 17:55 decoder.pyo
-rw-r--r-- 1 root root 17K Mar 4 17:55 encoder.py
-rw-r--r-- 1 root root 14K Mar 4 17:55 encoder.pyc
-rw-r--r-- 1 root root 14K Mar 4 17:55 encoder.pyo
-rw-r--r-- 1 root root 15K Mar 4 17:55 __init__.py
-rw-r--r-- 1 root root 14K Mar 4 17:55 __init__.pyc
-rw-r--r-- 1 root root 14K Mar 4 17:55 __init__.pyo
-rw-r--r-- 1 root root 2.3K Mar 4 17:55 scanner.py
-rw-r--r-- 1 root root 2.2K Mar 4 17:55 scanner.pyc
-rw-r--r-- 1 root root 2.2K Mar 4 17:55 scanner.pyo
-rw-r--r-- 1 root root 997 Mar 4 17:55 tool.py
-rw-r--r-- 1 root root 1.3K Mar 4 17:55 tool.pyc
-rw-r--r-- 1 root root 1.3K Mar 4 17:55 tool.pyo
In addition, I checked the md5 hash of the files above as a view of their content. It seems there is no content differences between the same files:
# md5sum ~/myImage/usr/lib64/python2.7/json/*
598c681c82c582ca3f17950b4d5413c1 /root/myImage/usr/lib64/python2.7/json/decoder.py
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage/usr/lib64/python2.7/json/decoder.pyc
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage/usr/lib64/python2.7/json/decoder.pyo
007a9954ca6641b29564a0f0cb55096b /root/myImage/usr/lib64/python2.7/json/encoder.py
366d44efbfce1e5b4a3397b15f202765 /root/myImage/usr/lib64/python2.7/json/encoder.pyc
366d44efbfce1e5b4a3397b15f202765 /root/myImage/usr/lib64/python2.7/json/encoder.pyo
dd5db0c7fb7c531be4e14feebbdb52e8 /root/myImage/usr/lib64/python2.7/json/__init__.py
791c8dca2a86ce50ead04e918a17b508 /root/myImage/usr/lib64/python2.7/json/__init__.pyc
791c8dca2a86ce50ead04e918a17b508 /root/myImage/usr/lib64/python2.7/json/__init__.pyo
8d6660f10863f99ffdd9a95eeddd7b64 /root/myImage/usr/lib64/python2.7/json/scanner.py
59865f486b742aea959693c04cfce057 /root/myImage/usr/lib64/python2.7/json/scanner.pyc
59865f486b742aea959693c04cfce057 /root/myImage/usr/lib64/python2.7/json/scanner.pyo
ad879e2ba247d3d4a5cc71fe22db91d0 /root/myImage/usr/lib64/python2.7/json/tool.py
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage/usr/lib64/python2.7/json/tool.pyc
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage/usr/lib64/python2.7/json/tool.pyo
# md5sum ~/myImage-copy/usr/lib64/python2.7/json/*
598c681c82c582ca3f17950b4d5413c1 /root/myImage-copy/usr/lib64/python2.7/json/decoder.py
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage-copy/usr/lib64/python2.7/json/decoder.pyc
939055a9fdfbbe6ab4d4babeb3ae63f5 /root/myImage-copy/usr/lib64/python2.7/json/decoder.pyo
007a9954ca6641b29564a0f0cb55096b /root/myImage-copy/usr/lib64/python2.7/json/encoder.py
366d44efbfce1e5b4a3397b15f202765 /root/myImage-copy/usr/lib64/python2.7/json/encoder.pyc
366d44efbfce1e5b4a3397b15f202765 /root/myImage-copy/usr/lib64/python2.7/json/encoder.pyo
dd5db0c7fb7c531be4e14feebbdb52e8 /root/myImage-copy/usr/lib64/python2.7/json/__init__.py
791c8dca2a86ce50ead04e918a17b508 /root/myImage-copy/usr/lib64/python2.7/json/__init__.pyc
791c8dca2a86ce50ead04e918a17b508 /root/myImage-copy/usr/lib64/python2.7/json/__init__.pyo
8d6660f10863f99ffdd9a95eeddd7b64 /root/myImage-copy/usr/lib64/python2.7/json/scanner.py
59865f486b742aea959693c04cfce057 /root/myImage-copy/usr/lib64/python2.7/json/scanner.pyc
59865f486b742aea959693c04cfce057 /root/myImage-copy/usr/lib64/python2.7/json/scanner.pyo
ad879e2ba247d3d4a5cc71fe22db91d0 /root/myImage-copy/usr/lib64/python2.7/json/tool.py
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage-copy/usr/lib64/python2.7/json/tool.pyc
af6b5531a8bc6977bca14e8d34ba8f68 /root/myImage-copy/usr/lib64/python2.7/json/tool.pyo
So, what is the reason behind the size difference of the same content in du output?
My operating system is CentOS Linux release 7.9.2009.
Is there any way to take away the owner's permission to read a file in macOS? I know there's no reason to do this but I have to for school and I can't find an answer anywhere. Removing my write permission works fine but when I try to remove my read permission it automatically give me my read and write permissions back. As you can see in the console when I use chmod -v -v (extra verbose) it shows the correct permissions it should be changed to but then when checking afterwards they havent changed into that...
thijs#Thijss-MacBook-Air-2 week6 % ls -l
total 16
-rw----r-- 1 thijs staff 12 Oct 11 21:10 greeting.txt
-rw-r--r-- 1 thijs staff 0 Oct 11 21:10 hello.txt
-rw------- 1 thijs staff 15 Oct 11 21:11 weather.txt
thijs#Thijss-MacBook-Air-2 week6 % chmod -v -v u-w weather.txt
weather.txt: 0100600 [-rw------- ] -> 0100400 [-r-------- ]
thijs#Thijss-MacBook-Air-2 week6 % ls -l
total 16
-rw----r-- 1 thijs staff 12 Oct 11 21:10 greeting.txt
-rw-r--r-- 1 thijs staff 0 Oct 11 21:10 hello.txt
-r-------- 1 thijs staff 15 Oct 11 21:11 weather.txt
thijs#Thijss-MacBook-Air-2 week6 % chmod -v -v u-r weather.txt
weather.txt: 0100400 [-r-------- ] -> 0100000 [---------- ]
thijs#Thijss-MacBook-Air-2 week6 % ls -l
total 16
-rw----r-- 1 thijs staff 12 Oct 11 21:10 greeting.txt
-rw-r--r-- 1 thijs staff 0 Oct 11 21:10 hello.txt
-rw------- 1 thijs staff 15 Oct 11 21:11 weather.txt
The following shows a few locations.
https://forums.docker.com/t/where-are-images-stored-on-mac-os-x/17165/4
But I don't see which file correponses to which image. Could anybody show me how to figure out the physical location of each image? Thanks.
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a06b2d5530d4 gcc:4.9 "bash" 3 days ago Up 3 days awesome_northcutt
99bfd1b8c105 ubuntu "bash" 3 days ago Exited (0) 3 days ago heuristic_clarke
16a89b2caa3c ubuntu "/bin/bash" 3 days ago Exited (0) 3 days ago xenodochial_lamarr
3137d54a035d ubuntu "bash" 8 days ago Exited (0) 8 days ago eager_napier
60714fa75fc4 hello-world "/hello" 8 days ago Exited (0) 8 days ago zen_pare
a78b73509455 hello-world "/hello" 8 days ago Exited (0) 8 days ago adoring_visvesvaraya
b5ea8abe5858 hello-world "/hello" 8 days ago Exited (0) 8 days ago brave_tesla
$ cd $HOME/Library/Containers/com.docker.docker/Data/
$ ls -Rg
.:
total 0
srwxr-xr-x 1 staff 0 Jan 2 19:44 backend.sock
drwxr-xr-x 3 staff 96 Feb 16 2018 database
srwxr-xr-x 1 staff 0 Jan 2 19:44 docker.sock
srwxr-xr-x 1 staff 0 Jan 2 19:44 osxfs.sock
-rw-r--r-- 1 staff 0 Feb 16 2018 task.lock
drwxr-xr-x 6 staff 192 Jan 2 19:44 tasks
drwxr-xr-x 3 staff 96 Jan 2 19:44 vms
srwxr-xr-x 1 staff 0 Jan 2 19:44 vpnkit.diag.sock
srwxr-xr-x 1 staff 0 Jan 2 19:44 vpnkit.eth.sock
srwxr-xr-x 1 staff 0 Jan 2 19:44 vpnkit.pcap.sock
srwxr-xr-x 1 staff 0 Jan 2 19:44 vpnkit.port.sock
./database:
total 0
./tasks:
total 16
-rw-r--r-- 1 staff 235 Jan 2 19:44 com.docker.driver.amd64-linux
-rw-r--r-- 1 staff 1064 Jan 2 19:44 com.docker.hyperkit
-rw-r--r-- 1 staff 343 Jan 2 19:44 com.docker.osxfs
-rw-r--r-- 1 staff 1337 Jan 2 19:44 com.docker.vpnkit
./vms:
total 0
drwxr-xr-x 18 staff 576 Jan 2 19:44 0
./vms/0:
total 7712512
srwxr-xr-x 1 staff 0 Jan 2 19:44 00000002.000005f4
srwxr-xr-x 1 staff 0 Jan 2 19:44 00000002.00001000
srwxr-xr-x 1 staff 0 Jan 2 19:44 00000002.00001001
srwxr-xr-x 1 staff 0 Jan 2 19:44 00000002.0000f3a5
srwxr-xr-x 1 staff 0 Jan 2 19:44 00000003.000005f5
srwxr-xr-x 1 staff 0 Jan 2 19:44 00000003.00000948
-rw-r--r-- 1 staff 63999836160 Jan 11 08:55 Docker.raw
-rw-r--r-- 1 staff 192512 Jan 2 19:44 config.iso
srwxr-xr-x 1 staff 0 Jan 2 19:44 connect
lrwxr-xr-x 1 staff 17 Jan 2 19:44 guest.000005f5 -> 00000003.000005f5
lrwxr-xr-x 1 staff 17 Jan 2 19:44 guest.00000948 -> 00000003.00000948
-rw-r--r-- 1 staff 2304 Jan 2 19:44 hyperkit.json
-rw-r--r-- 1 staff 5 Jan 2 19:44 hyperkit.pid
drwxr-xr-x 2 staff 64 Jan 2 19:44 log
-rw-r--r-- 1 staff 36 Jan 2 19:44 nic1.uuid
lrwxr-xr-x 1 staff 12 Jan 2 19:44 tty -> /dev/ttys184
./vms/0/log:
total 0
Docker does not run natively a Mac because the macOS kernel isn’t compatible (i.e., BSD vs Linux). Docker is actually running in a virtual machine using HyperKit.
And the Docker.raw you listed above is the virtual disk of this virtual machine.
All the docker image is stored inside the virtual machine (in the Docker.raw file), so you can not see them on the Mac filesystem.
screen ~/Library/Containers//com.docker.docker/Data/vms/0/tty
This command should take you to the required file system of docker on MAC
I intent to enumerate the files and dirs
[root#iz2ze9wve43n2nyuvmsfx5z /]# ls -lh |nl
1 total 60K
2 lrwxrwxrwx 1 root root 7 Jun 15 22:08 bin -> usr/bin
3 dr-xr-xr-x. 5 root root 4.0K Jun 15 22:10 boot
4 drwxr-xr-x 19 root root 2.9K Sep 17 11:35 dev
5 drwxr-xr-x. 85 root root 4.0K Sep 18 22:44 etc
6 drwxr-xr-x. 2 root root 4.0K Sep 17 08:25 home
7 lrwxrwxrwx 1 root root 7 Jun 15 22:08 lib -> usr/lib
8 lrwxrwxrwx 1 root root 9 Jun 15 22:08 lib64 -> usr/lib64
9 drwx------. 2 root root 16K Oct 15 2017 lost+found
10 drwxr-xr-x. 2 root root 4.0K Apr 11 2018 media
11 drwxr-xr-x. 2 root root 4.0K Apr 11 2018 mnt
12 drwxr-xr-x. 2 root root 4.0K Apr 11 2018 opt
13 dr-xr-xr-x 86 root root 0 Sep 17 11:35 proc
14 drwxrwxrwx. 21 root root 4.0K Oct 22 08:11 root
15 drwxr-xr-x 24 root root 660 Oct 24 19:10 run
16 lrwxrwxrwx 1 root root 8 Jun 15 22:08 sbin -> usr/sbin
17 drwxr-xr-x. 2 root root 4.0K Apr 11 2018 srv
18 dr-xr-xr-x 13 root root 0 Oct 21 19:50 sys
19 drwxrwxrwt. 11 root root 4.0K Oct 24 05:19 tmp
20 drwxr-xr-x. 13 root root 4.0K Jun 15 22:08 usr
21 drwxr-xr-x. 19 root root 4.0K Jun 15 22:08 var
It starts with 1 which I desire is 0.
How could make nl to enumerate from a specified line.
You just need to use the -v option, and specify to start from 0; your instruction becoming:
ls -lh |nl -v 0
Lets have a look at nl --help:
$ nl --help
Usage: nl [OPTION]... [FILE]...
Write each FILE to standard output, with line numbers added.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
...
-v, --starting-line-number=NUMBER first line number for each section
Therefore:
$ nl -v0 <<EOF
> a
> b
> EOF
0 a
1 b
Note that it does not really matter whether you want to enumerate directories or anything else, which is why you probably should strip this part from your question to make it more specific.