-
-
Save rbochet/755341 to your computer and use it in GitHub Desktop.
Shell script for printer cron (w/ lock)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Romain Bochet | |
# Use as a cron | |
# Print all the files included in a folder with lp, and move them in another folder. | |
# Use absolute path (mandatory for crons) | |
SOURCE="/home/dropbox/print/" | |
DONE="/home/romain/printed/" | |
LOCK="/tmp/printerlock" | |
# Test if another thread is running this script | |
if [ -f $LOCK ] | |
then | |
exit | |
fi | |
touch $LOCK | |
for FILE in `ls $SOURCE` | |
do | |
/usr/bin/lp $FILE | |
/bin/mv "$SOURCE$FILE" $DONE | |
done | |
rm $LOCK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment